Volcanoes can occur for a number of reasons. Normally, subduction of tectonic plates is involved. When one plate, such as the pacific plate, is pushed under another plate, such as the eurasian plate, the oceanic plate is put under extreme heat and pressure. This heat and pressure can turn igneous and sedimentary rocks into metamorphic rocks but if the temperature and pressure are high enough, these rocks melt to become magma. This magma is pushed upwards and as it moves, the surrounding rocks are strained by the heat and pressure. This strained rock can be deformed in orogenous (mountain building) areas. Plate tectonics along sea floor spreading is another example.
Most volcanoes form in this fashion but Hawaii is different. There is indeed magma involved but it the result of a "hot spot" under the crust. As the pacific plate moves, this "hot spot" leaves a trail of islands in its wake. Yellowstone national park is another example of a "hot spot"