Magma comes from an Italian word that means a thick, pasty substance, which is how molten rock behaves within the Earth.
Lava, another Italian word, means to slide, which is what molten rock does once it reaches the surface.
All magma contains dissolved gases. As it rises to the surface, the pressure is reduced and the dissolved gases can escape. If the lava is runny (not viscous), the gases can escape easily and the lava will just run down the landscape (somewhat like syrup).
However, if the lava is thick and pasty (highly viscous), the gases cannot escape and they build up tremendous pressure (like a shaken soda bottle) causing the volcano to erupt/explode violently forming volcanic ash, dust, pumice, etc., and lava.