A utility box holds a light switch or an outlet and the wires connecting it.
When you are putting a new box in an “old” wall you buy a box that says “Old Work.” These boxes have swinging flaps on two corners that hold the box tight to the drywall. “New Work” boxes have nails that you drive into a stud and you put up the drywall after all of the utility boxes have been installed.
This is an “Old Work” box.
Keep the box somewhere between the studs and at least an inch below or above any wood running horizontally between the studs so that the swinging flaps have room to pivot.
Make several shallow passes on each line with a utility knife to score straight lines in the drywall. It is better to go straight than to go fast or deep.
Keep scoring the drywall until you’ve cut the rectangle all the way through. If it is an outside wall you should be seeing the insulation.
Strip off about 8″ of the outer jacket of the wire. Then strip off about 5/8″ of the insulation of the white wire and the black wire. Push the wires in through the slots before fastening the box to the wall.
Now use a Phillips screwdriver to press the corner screws in and make sure that they turn the flaps easily. When you turn the screw to the right the flap should turn vertical. Turn the screws back to the left to put them down flush and then slide the box into the wall.
Hold the box to the wall nice and snug and use the screwdriver to push one of the screws all the way in before you start tightening the screw. If the screw isn’t pushed in first the flap won’t be able to rotate behind the drywall. Stop turning the screw when you feel the flap holding the box to the drywall. Those tabs are easy to strip so don’t overdo it.
Do the same for the other screw.
Now you can attach the wires to the switch or outlet, fold the wires back into the box, and screw the switch or outlet to the box. Screw on the cover plate and you are done.