What’s causing all the ebike and escooter battery fires?

A frame enclosure won't mitigate issues with a poorly built battery just because it's in the frame. Maybe it'll be less apt to suffer external damage in a crash.
I wasn't thinking along of the lines of mitigating it, just the opposite. I was thinking about the thing blowing up due to the intense heat created inside the enclosed space of the frame. Much like you see in flashlights that use very high powered lithium batteries. The ones in ebikes are even more powerful.
I was thinking about the thing blowing up due to the intense heat created inside the enclosed space of the frame.
The DIY community has a prejudice against enclosing batteries for the reasons you state.

However, there's a way to do it right. I've built bikes that have a battery permanently encased in a box. I have a temperature sensor attached to the pack so I can monitor what happens inside the box and to the pack. And I have the pack built with a cell model that does not run hot. Further, I build the pack big so it is more than capable of taking the load I'm going to give it without heating up, even if I didn't also choose the cells with heat and load in mind.

My 32ah Samsung 50T pack doesn't really get up over ambient air temps. In fact its typically below ambient even if the outside temp is well over 100 degrees (in the sun, which is baking the pavement that is radiating heat up and into the pack's alloy casing walls). I also lined the box with heat sinks that are good for about 3 degrees of cooling on the casing surface (when the bike is moving. Parking it on hot sun-exposed cement when its 105 out is to be avoided).

So... nobody does this, right? Not on factory packs for sure and precious few who DIY them. My point in mentioning all the above is just to note your question does not have a yes/no answer, since the pack may not be heating up at all in the first place, and to spell out why that can be.
The problem is the PVC overing on the battery. When connecting batteries in series, you go positive to negative by changing the direction of the battery banks until you get the desired voltage. Vibration can cause the battery PVC coverings to rub against eachother, expose their negative walls, complete the circuit and short circuit. Put a barrier between the battery banks and make sure the balance wires do not touch anything. When space allows. I suggest using a battery holder to stabilize the cells when building batteries.
Add this safety suggestion to the other known problems when building batteries. This is why some high energy batteries are double wrapped by the manufactures.

EZ Scooter Repair Shop, North Las Vegas, NV
Also, when I store my batteries, I keep the in the same direction. All th positive sides in one direction and the negative in the other.

EZ Scooter Repair Shop, North Las Vegas, NV