Basically because pouring on water doesn't serve to extinguish the flames. Because the petrol (gasoline) is fluid itself, and it doesn't easily chemically bond to water, petrol on fire will just be split up into smaller flammable chunks and spread about by the water; it won't get suffocated by application of water. So not only does water not put out the flames, but it may help to spread the fire around faster.
Whereas, if you pour foam on the fire, it stays put, chemically binds to the petrol and helps suffocate the fire burning on it. Bonus all around.
Whereas, if you pour foam on the fire, it stays put, chemically binds to the petrol and helps suffocate the fire burning on it. Bonus all around.