Static electricity is a phenomenon where the static charges formed on one body are transferred to another body.
There is a good chance that you might have static charges collected on your body. When you fill-up the gas, these static charges stored on you might ignite the gas causing an explosion.
On touching a metal pole or similar conductor, the charges are transferred to the ground. Thus avoiding a possible accident.