The time one might use an extinguisher is for an in-flight electrical/avionics fire. One could not put out an engine fire from inside the cockpit (obviously) - this is why you have the firewall, so you can do a landing before the fire propagates into the cockpit.
Another use might be to put out an engine fire starting on the ground, perhaps (though I think most people would just get out and leg it
).
Hard to believe today that some people smoke in an aircraft, isn't it? But they always have done - my plane has several ashtrays, so there's another clear requirement for an extinguisher.