Today I'll try to explain the hows and whys about airsoft replicas' insides. I'll start with the easiest -- gas guns.
First, excerpt from Wikipedia's "Airsoft" article.
Gas-powered airsoft guns use pressurized gas to propel pellets. These guns are capable of automatic and semi-automatic operation. The most common gases used are propane (usually referred to as "green gas" by airsoft players) and HFC134a refrigerant. Less commonly used gases include CO2 and nitrogen.
Gas-powered airsoft guns are somewhat gas-fueled. I mean that gas is pressurized outside of the gun, and is only released from gas container after trigger is pulled. The hammer hits the valve hard enough to open it, gas flows to the barrel and the BB is propelled. Nothing more. In winter valves like to freeze (decompressing gas causes a temperature drop). Some of the gas-fueled guns have so called "blow-back" system -- it is a mechanism (also powered by gas from container) that moves the slide or bolt to simulate the "real steel" gun operation and to create recoil.
Now, the spring guns. They're the cheapest, but the schematics of its operation is bit more difficult to explain. The mechanism of this gun creates the compressed air on its own, inside the gun. Imagine a syringe in which you have a piston attached to the spring. When you compress the spring you suck the air inside the syringe. After you release the spring the piston moves very fast and creates a flow of compressed air through the nozzle. The operation of a spring powered airsoft gun is very similar. The spring is of course compressed by the shooter (there's a mechanism that allows to do it with the same movement like while reloading a firearm).
The airsoft electric guns (AEG) also have spring, piston and cylinder. But this time the piston is moved by an electric motor, with the use of so called "gearbox". You pull the trigger, the engine starts and rotates the gears (three of them), the last one pushes the piston causing the spring compression. In the proper moment the piston is released. The rest is as in the spring gun. The only difference is that in this case most guns have fullauto option, allowing to fire up to 600 or more BBs per minute.