Why do jet engines sometimes spit out flames after ingesting birds?
As RedGrittyBrick has commented, what happened in that video is a compressor surge. This is not really an engine fire, but a temporary backfire. To understand what is happening, look at this diagram of a turbine engine:


The air is compressed in the front of the engine, fuel is injected and ignited, and then everything flows out the turbine section and the exhaust nozzle. The only thing supporting the compression at the front of the engine is the rotation of the compressor blades. There are many different things that could cause the compression to fail. In the event of a bird strike, these blades can be damaged.

When that happens, there is highly compressed air in the combustion section, and there is no longer enough compression to prevent it from exiting the front of the engine. This causes the air to exit both the front and rear of the engine. The disruption in air flow happens too quickly for the engine control systems to react. This means the engine is still pumping enough fuel to run the engine at normal thrust, but there is no longer enough air flow to burn all that fuel in the combustion section. The result is that the fuel burns through the turbine and exhaust section of the engine, and behind the engine.

Once this compressed air has exited the engine, it will generally recover. The engine is not on fire, so once the excess fuel burns away, the flames are no longer visible. However, if the problem is still present (and damage from a bird strike would not go away), then the engine surges over and over until it is shut down or set to a lower, more stable power setting.

So this is not so much a safety feature as physics taking over, and there is no real fire of immediate danger to the airplane. The engine system will automatically shut down the engine if it senses there is anything potentially very dangerous or that completely prevents the engine from running. While compressor surges can eventually damage the engine, it's not really a catastrophic event, and it is up to the pilots to assess the situation and shut the engine down if necessary. Reducing power to idle may sometimes be sufficient to stop the surges.

During a compressor surge, the flames are confined within the engine. There should be nothing to burn here besides fuel, so cutting off fuel will stop the fire. Actual engine fires are generally caused by flammable fluids leaking into hot areas around the engine, or the hot engine gases escaping from the air flow sections into surrounding systems. There are detection systems to alert the pilots of this situation, and the engine area is designed to contain a fire until the pilots can use the fire extinguishing systems to put such a fire out or at least get the plane back on the ground.