There are several different technologies that fall into the "catapult" category. They include the catapult, the ballista and the trebuchet. The catapult is the winched-down bucket that people normally think about when they hear the word "catapult" (see this page for a picture). A ballista is a very large crossbow (see this page for a picture). A trebuchet is a weighted beam that swings a sling carrying the projectile (see this page for pictures).
Both catapults and ballistas work by storing tension either in twisted ropes or in a flexed piece of wood (in the same way an archery bow does, but on a larger scale).
A trebuchet tends to be easier to build because it consists simply of a pivoting beam and a counterweight that rotates the beam through an arc.
Catapults can launch things a fair distance -- 500 to 1,000 feet (150 to 300 meters) is common. It is surprising how much energy they can store. The gears are important, because they create a winch. The winch allows a person to put a great deal of energy into the catapult over a period of time. Then all of the energy releases at once, throwing the projectile.
Here are some interesting links:
- How Force, Power, Torque and Energy Work
- How to Build a Catapult
- The Physics of the Trebuchet
- The Algorithmic Beauty of the Trebuchet
- Middelaldercentret: The Medieval Centre in Denmark
- War Engines of the Middle Ages