Both hydrogen and oxygen fuel flame, but together they make water and that can put out a flame. Why?
In a sense, water is the “ash” that forms when hydrogen burns in oxygen. Like all fully burned materials, water can’t burn any further. When you put cold water on a fire, it extracts heat from the fire because the water is much colder than the fire and heat naturally flows from hotter objects to colder objects. Since heating the water doesn’t cause the water to burn (it can’t burn), the heat that’s lost by the fire doesn’t create new fire (as would be the case if you threw gasoline on the fire instead of water). So the water gradually cools down the fire until the fire no longer has enough thermal energy to sustain its own chemical reactions. The fire then goes out.