We know, fire extinguisher has a red metallic vessel containing a sodium bicarbonate solution and a bottle of sulphuric acid. When we need carbon dioxide gas to extinguish a fire, the vessel is inverted. Afterwards, the bottle of concentrated sulpheric acid strikes against the floor. The plug of the acid bottle falls down and and comes in contact with the sodium bicarbonate solution. When those chemical react together, they give carbon dioxide gas.
2NaHCO3 + H2SO4 ----------> Na2SO4 + 2H2O + 2CO2↑
The gas produced in the above reaction comes out from the nozzle at high pressure and put off the fire, just like putting a blanket over the surface of the flame.