I don't think it has anything to do with static electricity (which can happen anytime, always touch your car before the pump handle!) or your engine being hot. More likely its to cut down on as many extra factors as possible that could ignite the vapors. How ever unlikely it is to happen consider this, with the engine on(or even just key switch on) there are many moving parts that could cause some type of spark. There are also many more live electronics in the car that could fail spectacularly at anytime. With the engine/switch off these items are dormant so it greatly reduces the chance they could ignite any fuel vapors.
Side note,
I was at the pump across a guy once who was fueling his scooter. He either had it running or he went to start it while fueling. It caught a small fire directly above the tank. He tried to extinguish it with the bottle of water he was drinking which made it worse, then he tried his shirt which also caught fire. There was no explosion but it grew steadily til it consumed his scooter and then the entire pump. I had my 3yo son at the time in the back seat so I stopped pumping and got out of there at this point.
The wawa station at the time had the fire extinguishers hidden behind trash cans on the ground. They have since moved them up higher where they are more visible.