I'm assuming you are talking about the load center (and that it's similar to mine). It normally hooks in via a couple of screws into the edges of the plywood.
The gotcha in playing with it is that you have both 12V
and 120V in the box. Disconnecting the 120V is pretty easy ( don't plug into shore power ). The 12V
involves lifting (= disconnecting ) the negative wire to the battery.
Once you have the power off, *gently* try to work it back into place. You very much do *not* want to pinch any wires as you get it back in there. Assuming it slides back in ok, you then just have to re-attach it to the cabinet frame.
How you attach it depends a bit on how it parted company with the frame. Best guess is that the screws stripped out. They also could have broken. It's possible the wood actually broke. Each issue would require a slightly different solution. There are to may variables there to randomly toss up ideas without more information.
So - how did it break free ( = what separated as it came loose ) ?