Two of the last three houses I've lived in had front panels that no longer fit, so you needed to take care when operating the breakers. In the older one, we tripped a breaker and about half the lights in the house went out. I went hunting for it and eventually went to flip off the main to start a more thorough check, only to find that is what had tripped, leaving half the house on... About half my 120 and all my 240 breakers were wired direct to the bus bypassing main. I'd love to hear a pro's stories. I bet they see really weird and terrible stuff.
FWIW: Poorly-fitting panel covers would never pass an inspection and are inherently dangerous. It's really important for the panel to be enclosed. Humidity, dust, vermin, and fingers get in. Sparks get out. Your home insurance would be worthless in case of a fire. Never mind the risk to irreplaceables.
But re: tripping the main -- this is likely a fault in the breaker itself. It's not likely that a faulty line breaker allowed enough current to trip the mains breaker (though it does happen, but see below). Of course several overloaded lines can trip the mains, but this is exceedingly rare. A fault in the mains breaker is a serious problem for sure. However, unless you inspected the wiring yourself, I'd hesitate to assume that it was miswired as you describe.
In standard US residential service, you get two 120V lines ("legs"). If the mains breaker failed, it's possible to lose one of those legs to the buss that supplies the line breakers (and the house fixtures), while the other leg stays up and powering the "other half" of the house. In this case, 240V appliances will appear to be "out" because they are only getting partial power (240V is really just two 120V services, 180degrees out of phase).
So I'd guess the cause was a failed/fatigued mains breaker. That's a job for an electrician, regardless, who would surely notice miswiring if present, and the other code violations that you definitely had.
The inspector did fail it, and has failed every house I've ever had inspected. The inspectors for my buyers also failed it. People just kind of live with it on old houses. Never thought about it making an insurance claim fail. So the main breaker only turns off one leg? Why wouldn't you have one for each.
The mains breaker controls both legs, but they are separately protected. So if a protection sensor fails, it might only interrupt one leg. The switch controls both legs though.
I've done a lot of electrical work in old houses, but only in big cities where a failing inspection is just not tolerated. I've seen old country homes where regulation is ... less strict. This might not be an urban/rural divide, but that's my experience having lived in both.
I'm amazed that you were able to buy or sell a house that did not pass inspection. If the buyer was financing, the mortgage would require insurance, which would require inspection. In a cash sale, the buyer should be sophisticated enough to take responsibility for the repairs.
I think (in my high-regulation states) it's actually not legal to sell a house that does not pass a safety inspection. At least not without surrendering the certificate of occupancy until repairs are completed and inspected.
These houses have all been in the DFW metroplex, so low regulation TX. The people that bought the terrifying breakerbox had a first time homeowner loan and the lender complained about some of the vegetation being too close to the house, but somehow the box was ok. I turned the main breaker on and back off, and half the lights were still in. Weird one. All the outlets that had a ground hole were actually grounded, most of my friends have houses with fake grounds, knob and tube or worse, aluminum wiring. Regulations are sometimes a good thing. Its probably why our houses are cheaper though.
Couldn't it also be a really old style of panel without a singular main breaker, either falling under the "rule of 6" or perhaps dating from before it?