Earthquakes occur when there is a sudden release of energy in the Earth's crust, causing seismic waves. This release of energy is typically the result of tectonic plates shifting along fault lines or volcanic activity. The movement of these plates can cause stress to build up in the rocks along the fault line, eventually reaching a point where the rocks break and shift, resulting in an earthquake.