Oceanic crust forms at mid-ocean ridges. Magma rises from the hot mantle and erupts onto the ocean floor. The new crust moves away from the ridge, carried by the conveyor-belt motion of plate tectonics. As it moves away, it cools and becomes denser. Eventually, it sinks back into the mantle at subduction zones.
Continental crust forms when continental plates collide. The collision causes the plates to thicken, and the rocks within them to melt. The melted rocks rise to the surface and erupt to form volcanoes. The new crust is added to the edge of the continental plates.