The three main types of rocks are igneous, metamorphic and sedimentary. Igneous rocks as suggested by their name are rocks which are formed due to the cooling of magma expelled from volcanoes. metamorphic rocks are rocks which have been morphed either by heat, pressure, or by both. Sedimentary rocks are rocks formed due to the continuous sedimentation of rock particles on the surface, building up layers and layers of rock along time.
Rocks are converted into different types by a process known as the rock cycle. The rock cycle starts with sedimentary rocks. The rock is in the form of particles and keeps getting deposited on the surface of the earth. The particles build up layers over a very long period of time, in the process being lithified. And sedimentary rock is born. This sedimentary rock is now deep down, and under the influence of very high temperature and pressure melts, gets compressed, whatnot and becomes what we call metamorphic rock. Metamorphic rock as a rule, along with sedimentary rock due to uplift and exposure can actually rise up out over the surface, and weather, get transported and settle on the earths surface to form sedimentary rock. The metamorphic rock that does not rise up further gets exposed to temperature and pressure. Then, it melts in magma pools far under the surface of the earth. Then, it is expelled as igneous rock out of volcanoes where it flows and settles and then gets weathered and transported. And with this, the long cycle starts again.
Check out the graphical representation of the rock cycle to have a better understanding.