In order to understand how fire extinguishers work, you first need to know a little bit about fire.
Four things must be present at the same time in order to produce fire:
Oxygen, heat, and fuel are frequently referred to as the "fire triangle." Add in the fourth element, the chemical reaction, and you actually have a fire "tetrahedron." The important thing to remember is: take any of these four things away, and you will not have a fire or the fire will be extinguished.
Essentially, fire extinguishers put out fire by taking away one or more elements of the fire triangle/tetrahedron.
Fire safety, at its most basic, is based upon the principle of keeping fuel sources and ignition sources separate.