Hard to say. A picture would help, especially if you can take the cover off.
Some components can generate a lot of heat when they fail, and there's a lot of power going into a water heater, so enough to burn many things.
Without seeing it, it's totally a guess, but sounds like something shorted out and before it blew, acted like a big heating element, then burned itself apart.
I'm a big fan of a whole-house surge suppressor installed at the entry panel. It's cheap insurance for those things you don't put a separate one on. IT won't help with everything, but keep in mind that spikes/surges act like an ax, damaging some electronic components one chop at a time. You don't fell a tree with one chop, nor does the typical surge/spike (although a really close lightning strike can). A whole-house surge suppressor can extend the life of everything in the house. Note, some surges can be generated within the house from a motor turning on (but mostly when turning off as the field driving it collapses). Stopping surges in the whole house can make a difference. Lots of companies make them. I sort of prefer those from Mersen, which mostly makes industrial products, so not as well known in the residential market. As a result, they don't have the big name recognition, and thus, the price for the same quality unit.