Rock Doctor,
Avgas would be stored in the ships hull, just like feedwater, fuel oil or diesel for auxilary generators. With a midships, above the main deck hangar, your fuel lines from that storage would be running a deck or two higher than with a stern, 'in the hull' hangar,' and more exposed to damage. But assuming DC is up to snuff, perhaps caused by a careless sailor's cigarette. You've got an inert gas system to fill the fuel lines when they're not in use, etc. (USS Saratoga, CV-3, used a regular internal combustion engine to fill them with CO after Lexington's loss...) The aircraft themselves still represent a fire hazard. There's always going to be avgas vapor in their tanks, even if all remaining fuel is removed from them. Then there's an amount of oil in their engine, fabric coverings, etc. (Planes as late as the Corsair and Spitfire had fabric covered control surfaces, even though the bulk of their skin was stressed metal. )
The location of the fire is the bigger hazard, in my opinion. With a stern location, if fire breaks out, there's very little for it to damage. And it can only spread in one direction, forward. With the midships hangars, fire can spread both fore and aft, and in the middle of the superstructure, things like secondaries, AA mounts, directors, control tops, etc can all be made untenable by smoke, let alone the threat of the fire itself. Under the deck there are things like ready-use ammunition and potentially secondary magazines. And as you point out, the machinery is right there, too. The intakes for the boiler rooms could be ducted farther away, but smoke could still be a consideration. Plus why poke more holes in the ship than necessary? The risk would be drawing smoke in to the boilers, not healthy for the 'black gang' or the fires their tending. Cutting off fresh air intake isn't an option in an extended engagement, either. The fires need air, let alone the men. And boiler rooms without adequate ventilation can easily go over 100 degrees F. Sitting in the sun in Singapore's drydock, Prince of Wales boiler rooms rose to 130 degrees, and the boilers weren't even lit!
Regards,
Big Rich
edited for type