What does prevent air and fuel to be mixed upstream of the compressor?
tl;dr The flame would progress upstream into the compressor until it and damage it, fatally disrupt the carefully balanced flow and stall the engine, or both.

long answer: In a turbine engine, there is a continuous flame where injected fuel is ignited by the already burning fuel downstream. Now you can't match the flow speed and the flame propagation speed exactly, because a small disruption could then blow out the engine and because both depend on the power setting in non-trivial way.

So in normal operation, the flame can propagate upstream until it gets to the point where the fuel is not yet sufficiently mixed with air to burn and there it stays. If you injected the fuel before the compressor, the flame would progress into it and as it would engulf the last stage, it would damage it and it would also increase the pressure beyond what the preceding stages could maintain, which would stall the compressor and cause the engine to stop, either immediately due to lack of oxygen, or by causing more damage with each stall cycle.

Note that spark-ignition (gasoline and LPG and CNG) engines usually do inject fuel before compression, but it limits their compression ratio to around 12:1 with high-octane gasoline, 14:1 with clever tricks. If the compression ratio was higher, the fuel-air mixture would ignite from the compression heat before the piston reaches the top-dead-centre and act against the rotation. In contrast compression-ignition (Diesel) engines have compression ratio at least 14:1 and inject the fuel only when it should start burning.

While early turbines had rather low compression ratios, the newest generation is getting into the range comparable with Diesel engines where the fuel might ignite due to the compression heat alone—they still use sparks for ignition, because the starter won't build up as high pressures in them, but it clearly shows they can't inject the fuel before it should start burning.