Why do earthquakes happen?
The short answer
Moving plates can build stress in rocks. When a fault suddenly slips, the released energy travels as seismic waves.
How it works
Rocks can deform, but friction may lock a fault while stress accumulates. Once the stress exceeds the strength of the rocks, the fault slips and waves travel outward. Ground conditions also affect the shaking people feel.
A familiar example
Shaking can differ within the same area because soil, rock, and building conditions are not identical.