Pressure.
The is made up of different plates. These plates move. Some move away from each other, but others push or slide against each other.
When plates move away the molten magma to from the earth’s core comes up. When this magma cools it forms rock (igneous). Over time and as the rocks move further away, the rock gets bigger and bigger until it forms a volcano.
But, when plates push or slide against each other then pressure builds. this pressure builds and builds until there is a sudden jolt. This jolt is the earthquake.
And that is why earthquakes occur along plate boundaries.