When I was 14 I put together a Matchless G80 from boxes of parts. On the maiden run down our long driveway,and with friends looking on, it backfired. The Carb, which had a sticking float, caught on fire. I was riding back toward the house, unaware of the flames, until my friends started shouting and pointing. At that point I stopped and ditched the bike (no stand fitted yet) which had a full tank of gas. The fuel then started pouring out of the tank vent, which increased the flames greatly.
My mother saw this from the kitchen window, grabbed a small box of baking soda and a large box of salt. She ran out and threw the baking soda on first, that got most of it out and the salt did the rest. The damage was mostly to my newly painted tank, and at that only to the tank itself.
In general, water does not work well with a gas fire, it tends to make things worse. It might be possible to put out a gas fire with water I you could completely engulf the flame with water, but spraying with a hose doesn't work well.
Baking soda or salt work great.
Glen