types of rocks are formed when magma from volcanic activities cools down and crystallizes
If magma makes it to the surface it will erupt and later crystallize to form an extrusive or volcanic rock. If it crystallizes before it reaches the surface it will form an igneous rock at depth called a plutonic or intrusive igneous rock.