The reason they tell you to turn of your engine is because modern fuel pumps are submerged electric pumps that are located in the fuel tank.
These pumps generate electric sparks (not sometimes, all the time), there is arcing between the brushes and the commutator. Usually with the fuel filler cap closed, a vacuum is created so no oxygen is present. If oxygen where to reach the sparks generated by the fuel pump it would ignite and probably explode. Although fuel doesn't usually explode if you light it, a fuel tank is under pressure so the sudden change is pressure inside the fuel tank is likely to cause an explosion.
Fuel is ignited by heat, not sparks or lighter buds. So technically a cigarette could light petrol but generally it's not hot enough (I think on a REALLY hot day with low octane hot petrol it could be done). Sparks, generated either by fuel pump, spark plug, your hair or lightning are all based on the exact same principles, it's just the amount of current that differs. ESD (electrostatic discharge) from your hair or skin is just as likely to light petrol (especially gasoline vapor) as a spark plug, both just need oxygen and fuel vapor. ESD causes the air around the spark to become super heated, hence the danger.