Volcanoes can be formed three ways. These include inter-plate activity, where magma pushes up between cracks in tectonic plate boundaries; the drift of hotspots in continental plates, which pushes magma through the surface; and magma chambers opening up beneath the earth, which cracks the surface and forms volcanoes.
In general, volcanoes are formed by magma pushing through from the Earth's mantle into the crust. When the lava cools and hardens, more lava builds up on top of it. This layering results in volcanoes. The magma is pushed through the Earth by pressure, which can be caused by either a build-up of pressure in magma chambers or by the activity of the tectonic plates. Around the plate borders, magma can easily flow up through the cracks. Hotspots in the plates themselves can also push through the surface, so when the plates shift, the hotspots move and create new volcanoes.