Compaction and cementation presses the layers and sticks the particles together. This creates sedimentary rock. Rocks underground get heated and put under pressure, and are changed into metamorphic rock. ... When the magma (lava) cools quickly, it turns into solid extrusive igneous rock.