This is basically the rock cycle and it is explained and showed in pictures. (For School)
The magma in the volcano rises to the surface.
When the lava on the surface starts hardening it forms igneous rock.
The metamorphic rock starts melting and turns to magma and this process goes over and over again
When a process called erosion happens when weathering breaks down the igneous rocks and blows it away into a certain spot
Those sediments would collect go in a process called deposition and deposition is when sediments collect in a spot and after thousands of years those sediments form a new type of rock called sedimentary rock.
When the sedimentary rocks form underwater heat and/or pressure compresses it into a metamorphic rock.