I've never had a box that moved too much after I trimmed it out. If your drywall is cut correctly, the straps of the devices will push against the wall surface when you are done, helping prevent movement. The cover helps as well.
Make sure the side of the box is firmly against the stud, and the nails are driven tight.
If you're concerned about it, place a small piece of scrap lumber between the two studs.