There are a few different mechanisms that I know of. As the tectonic plates move around, they generally either move apart in a spreading zone (like down the middle of the Atlantic Ocean), or squeeze together in a subduction zone (like around the rim of the Pacific ocean).
In the spreading zone the Earth’s crust is thin, so the hot mantle is nearer the surface. The heat melts magma, which creates the volcanoes. This process makes new crust, which attaches to the tectonic plates and slowly moves away from the spreading zone.
In a subduction zone the two plates are forced together, and one plate is forced under the other and into the mantle. This melts the plate – the frictional forces are seen in earthquakes, but also generate the heat for volcanoes.
A third mechanism I know of is a hotspot volcano, like in Yellowstone. There are about 20 or so points around the Earth where, for some unknown reason, there is a plume of hot mantle reaching up from near the Earth’s core to the edge of the Earth’s crust. This heats up and melts the crust, causing volcanoes.