Earthquakes and volcanoes occur in the same places because they both happen along the Ring of Fire. The Ring of Fire is located along the edges of a major tectonic plate.
Earthquakes are caused when tectonic plates shift and push over each other. The place where this happens is called a fault line. The shifting of the plates causes movements on the surface of the Earth that feel like an earthquake, and as the plates are constantly in motion, they naturally bump against each other over time.
Volcanoes are formed when magma from the interior of the Earth works its way up to the planet's surface. The excessive movements of the plates along the Ring of Fire causes the rock to melt into magma more easily, leading to more regular volcanic eruptions.