The compression ratio of an F1 engine is very high. It takes energy to compress the air and fuel mixture. Therefore there is a power loss with compressing before igniting the fuel mixture. Think of compressing a blocked bicycle pump.
When the engine is off throttle you may say, there is less air in the cylinders to compress, but there is still a resistance to compression from the little air present on compression stroke, and also the resistance to "stretching" of the air between the closed throttle plate and the pistions on the intake stroke.
Think of the intake stroke with a closed throttle as blocking a vacuum cleaner with you hand (throttle plate) and then notice the increased load on the motor.
The engine braking effect is can then be said to be the retardation of the crank shaft when the throttle is closed due to the combination of friction between moving parts, and resistance to compression of the air (doing work on the air). We call this friction power.
And here's a break down of why friction power decelerates the car when you come off throttle:
Brake horsepower (the power at the flywheel) = indicated power (power produced by combustion) - Friction power ( caused by friction of the moving parts, the resistance from compressing the air)
Now when you go off throttle, you take out the fuel injection and ignition, so the indicated power variable goes to zero.
So Brake Horse power = 0 - Friction power
Bp= -Fp.
The negative is not negative power, but it indicates the direction of power flow across a system boundary. The engine is no longer producing power to over come a load; it's no longer putting power out of the sytem. It is now behaving like a load, it is drawing power from outside into the system!
that is the simplest mathematical/ thermodynamic explanation of it. The engine is now a load. The momentum of the car will now go through the drive train and act to overcome the friction. the flow of power is now reversed. This engine in nothing more than a power absorber; a overly complicated air compressor

and like any air compressor it needs to be powered. Conveniently it will take this power from the car's momentum.
The same applies to KERS charging, and also alternator charging. The teams may use these retarding effects to have an input on the car's dynamics, since they can slow the car without the use of the brakes and that's a good thing, since the car's stability is not upset drastically.