Image credit: Scott Brande
Any pre-existing rock - sedimentary, igneous or metamorphic - may be heated and/or squeezed within the earth. The product of this process is a metamorphic product that has been transformed from the pre-existing rock, termed a protolith. The possible pathways of transformation are as simple or complex as the geological events producing heat and pressure, from a simple igneous intrusion, to complex plate tectonic motions. Metamorphism can even proceed backwards, termed 'retrograde'!
The diagram below is an extreme simplification of the many possible pathways for the origins of a limited set of common metamorphic rocks.
Click to enlarge.