Earthquakes occur when there is a sudden release of energy in the Earth's crust, typically caused by the movement of tectonic plates along fault lines. The stress that builds up between the plates is released in the form of seismic waves, resulting in the shaking of the ground that we feel during an earthquake.