Volcanoes and earthquakes are strongly related. For instance, if you look at a map of earthquakes around the planet and compare it to a map of volcanoes, you'll find that they match closely. Both earthquakes and volcanoes occur at the boundaries of
tectonic plates, which make up the Earth's surface. Earthquakes are caused by the release of pressure built up when the plates spread apart or move past each or under each other. In slightly more complicated ways, magma is generated at most plate
boundaries, and this magma rises to the surface to form volcanoes.
The movement of magma within a volcano causes earthquakes, usually small ones. Earthquakes are also caused by adjustments to the flanks of volcanoes and the plates under volcanoes.