Not 100% sure I got the gist but a couple thoughts - 1 - If the electrical gang box ears (which holds the box in place) are broken... a) could you buy and install a new box, or b) buy and install a box bracket or switch box straps, c) there's also this repair clip
Measure your dimensions first
2 - If you have to replace the drywall - hardware stores (HomeDepot, Lowes, etc.) now sell small pieces of dry wall. You'll need a few things for this: - ruler, pencil, razor blade/cutter, drywall patch, drywall spakle/compound, drywall tape, a spakle/putty knife, and sand paper.
Here's a video
Disclaimer - I'm not a professional, just a contractor's daughter with her fair share of home improvement mishaps!