The posts above kind of cover the "how" so I'll talk a little about the "why." Sort of another viewpoint along the same lines (but the above is pretty good, too):
Ok, so the compressors add energy to the airflow by spinning, right? And as we know, the compressor blades are each like a little mini wing, or airfoil in the flow, and they are arranged in a big disk. But there is not just one disk of compressor blades (at least not on any engine I can think of), but instead there are many different stages of these disks, and all of the stages are connected at the center of the disks to the same rotating shaft. Hence, all of the stages rotate at the same rotational velocity (for the simplest jet engines anyway. Many engines use two different sets of stages: a low pressure compressor which is sometimes called a fan section, and a high pressure compressor. In that case, all the stages on each "set" rotate at the same speed, but the two different sets rotate at different speeds, usually called N1 speed and N2 speed).
Now, if there were no stators the air would come through the first compressor stage and that stage would impart some rotation to the air. When it got to the second set of spinning blades it would already be spinning at almost the same speed as the second set of blades. Hence, without stators, there would be very little relative or maybe NO motion between the air and the second (or third, fourth, fifth, etc.) sets of blades. So those follow on stages would not do anything.
So to remedy the problem, between each rotating disk of blades that is attached to the central spinning shaft, there is another disk of blades that remains stationary. Those blades are attached to the engine shroud.
The result? Well instead of the first stage of blades imparting a spin to the air, (and the follow on stages doing almost nothing), the air just gets squeezed... Hence the name "compressor".
By the way, the turbine has spinning blades (rotors) and stationary blades (stators) also. Works the exact same as the compressor, except in reverse. Instead of the blades spinning causing the air to get squeezed, the squeezed and heated air releases that energy by un-squeezing and turning the turbine blades.
From an energy standpoint you can think of the air like a spring. Compressing the air in the compressor (and then heating it in the combustor) is kind of like squeezing a big spring. Energy is stored in it. Once the energy is in the air (or in a compressed spring) it can be used to cause things to move. A squeezed spring could be placed behind a toy car, for example to launch it down a race track. The compressed and heated air pushes against the blades of the turbine to spin them (like when you blow on a pin-wheel).