Volcanoes are formed through the movement of magma and tectonic plates. Magma either pushes up through the middle of a lithosphere plate or around the boundaries of two plates, forming a volcano.
When magma is produced around plate boundaries, it is called interplate volcanic activity. This activity is caused by unusually hot mantle material forming in the lower mantle and pushing up into the upper mantle. The mantle material then forms a plume shape and wells up to create a hot spot under a specific part of the Earth's surface. Due to the unusual amount of heat within the mantle material, it melts and forms magma that is just under the Earth's crust.
The hot spot, where the magma spews forth, remains stationary, but as the continental plates move over the spot, the magma will begin creating strings of volcanoes. These volcanoes will eventually die out once they move past a particular hot spot.
Most volcanoes are created through subduction zone volcanism or hot spot volcanism. The structure of a volcano depends on a number of factors, primarily the composition of the magma. Additionally, unlike land volcanoes, the magma produced at ocean ridges just hardens to form new material for the Earth's crust.