Did you know that ordinary things like gasoline and wood don't "burn" the way most of us think they do?
Burning has been described historically by the "Fire Triangle" which consists of fuel, heat and oxygen. Unless all three legs are present in the right amounts, there will be no fire.
A more modern approach to the 3-sided explanation adds a 4th side (chain reaction in the diagram) called Pyrolysis. Pyrolysis is a thermo-chemical process that can occur at high temperatures and changes the fuel. While it does not need oxygen to perform its magic, it introduces both a chemical and physical change to the fuel.
When we watch things like wood or paper burn, it is really hard to tell there is all that chemistry and physics going because we can't see it.
For a piece of wood to burn, it must first be very hot. As the wood heats up, Pyrolysis begins to change it into a flammable gas. A very hot gas.
When this hot gas is allowed to combine with Oxygen there is an exothermic (heat and light are given off) reaction. This reaction is what we actually see and feel as "burning."
Once the fire becomes hot enough to keep itself going by the heat that is given off in the chemical reaction, it is referred to as self-sustaining.
To stop a fire once it has become self-sustaining, we need to remove one of the 3 legs of the fire triangle - the fuel, heat or oxygen whichever is easier.
When we put water on a fire, it actually does two things at once - it lowers the temperature of the fuel which helps stop Pyrolysis and it partially displaces oxygen. If we put enough water on to lower the fuel temperature below that at which Pyrolysis can occur, the fire will go out.