I had that happen a couple of months ago. I had the two boys in a 12g divided tank and was working at the computer when something made me look at the tank. WHOOPS! sparky had got through the divider and was going at spike! I threw (figuratively speaking) him back onto his side but I couldn't figure out how he got out.
He got out 3x over two days, with me happening to be there just in time to throw him back every time, and completely flumoxed as to how he was doing it. (not to mention stressed and having nightmares about what was happening in the tank when I finally had to go to bed.)
Because the plastic side holder (thingy) of the divider wasn't long enough to reach from the top of the tank to the bottom of the divider I had buried the bottom of the divider in the gravel. I kept my eye on the tank hoping to catch him in the act and I finally did! I had been concentrating on making the *top* of the tank secure, figuring that he was jumping over. Nope!
I had cleaned the tank the day before and hadn't noticed that the gravel had been disturbed so that it left a tiny (and I do mean tiny!) space between the top of the gravel and the side piece. sparky had found the hole though, and it was just big enough for him to squeeze through. What a wretch!
I stuffed a silk plant in the hole to fill it but he kept going back and trying to find a way through. you could just see him thinking, "I got through here before, there must be a way..."
(sorry about the long post!)