The earth is made of tectonic plates which used to be 1 continent called pangea. The same coastlines align like a jigsaw as they got separated by continental drift. Plates move in 2 ways - ridge push (away) and slab pull (slide over) due to convection currents (cycles of heat). The direction of convection currents is the same as the direction the plates move.