The magma that melts in the upper mantle and erupts at the mid-ocean ridge has a different composition (higher in Ca, Mg, Fe and relatively lower in Si and Al) than the composition of the magma (more Si, Al, Na, K rich in relative terms) that built the continents. Melting different degrees (2%, 5%, 30%) of a rock with a mantle-like composition generates magma of different Al, Si contents. Continents grow at their edges by partial melting of oceanic crust that is being subducted, generating magmas of a somewhat more Si, Al-rich composition than the subducting slab itself. The chemistry and physics of melting a mixture of minerals rather than one homogeneous substance has the wonderful outcome of creating two distinct types of crust:
When granite is exposed to elements such as wind and water, it weathers and erodes and the particles are deposited. Pressure causes these and other particles to form sandstone at Earth's surface. ... Increased heat and pressure will change the sedimentary rock into metamorphic rock.