In order to understand why water extinguishes fire, it is necessary to know the necessary conditions for the existence of fire, which are basically heat, oxidizer (oxygen) and fuel. When we remove one of these three components from the fire, it goes out!
However, eliminating fuel (material being burned) is very difficult, and removing oxygen from the air as well. So all that remains is to remove the heat from the reaction.
Then comes the water, which reduces the temperature of the place, thus removing the heat existing in the reaction.
However, water does not extinguish all types of fire.
Fire can be classified into 3 distinct classes, which depend on the origin of the fire. These classes are: A, B and C.
Fire A is the only fire that can be used with water as it will react with the cooling process. This fire usually originates from solid materials such as wood, fabric, paper…
Class B fire originates from fuels such as oil, gasoline, kerosene, alcohol, etc. This should be quenched, usually using chemical powder or chemical foam.
Class C fire is that which occurs in electrical equipment. Water or any equipment that has water cannot be used while there is power, as water becomes conductive to electricity. Then the chemical powder should be used.