I have an electrical box that was metal and i want to add another switch. I pulled out the old box and want to replace it. There was no ground to the box, and the wires do not have a ground, so I was going to use a plastic box. The only problem is the remodel box sticks out an extra inch because the stud isn't a normal 2x4. If I use an electrical box like this, can I just nail the front piece to the stud, or do I have to drive in the two long nails to the side of the stud?
If the box is not required to hold the weight of a light fixture it need only be securely fastened.
For example, you can get a 3-gang "old work" box designed to be attached only to the drywall. Which one you pick can have more to do with what cable is coming into the box: NM vs metal jacketed.
It sounds like you have access to the stud since you have removed the old box and expanded the drywall. The box you picked happens to nail to a stud rather far back. But there are other options. It may be difficult to reach the mounting points of a metallic switch box but you can nail into the stud with a metallic masonry box instead.