WHY does a jet engine work?
Some energy from the expansion is used to turn the turbine which powers the compressor


And in some engines it turns the turbine which has a large fan attached to the other end. The engine produces more power than needed to run itself.

Inside the engine, everything is a very careful balance of pressures. Basically the job done by valves in a piston engine is done by careful engineering in a turbine, which is one of the reasons they cost so much. The inflow to the combustion chamber balances the outflow to the power turbine to the point where it wants to go that way - get it a little bit out of balance and you have noisy stalls like you see in the referenced video.