How do medieval siege machines work?

Siege engines is a very broad term that encompasses a variety of technology.

The fundamental tenant of a "siege engine" is that it will help end a siege. A siege is referred to as limiting access to a fortified position, then trying to conquer or outlast the defenders. This is traditionally thought of an army attacking a castle in the medieval times but can include a multitude of locations including simple geographic features or a home.

In medieval times siege engines had three times:

1) Man powered

2) Simple machine enhanced

3) Chemical reaction powered

A man powered example includes a tunnel being dug under a wall, a battering ram, or even a ladder. Yes these are simple machines but the primary effort is from manual labor.

A simple machine enhancement usually gains power from a spring effect or from gravity. It is the most normal idea of a siege engine, it includes the catapult, the ballista, and trebuchet. All of these machines rely on gravity or a tension to increase the speed of a projectile. If you want an example, look at sports. Using a stick to hit a ball greatly increases the speed of the ball, that is because the outside of the arc swings faster than what you can move your arm.

The third type relies on chemical, usually fire. Early guns were siege engine cannons. Also fire was a classic siege engine. Fire was lit on the doors, flaming arrows, or burning the walls of wooden forts. All provided extra effort.

Siege engines were all intended to kill the defenders or to damage their protection. A defender can have a huge advantage in combat, so the engines help negate some of those advantages.