>>12341354When the proto-Sun formed the gas and dust around it began orbiting it's mass the angular momentum caused the gas cloud to flatten into a disk. Gravity caused all the gas that didn't fall into the Sun (less than .1% of the total mass of the cloud) clustered together to form planets orbiting in roughly the same plane as the original gas disk. It's also why the planets generally rotate the same direction (with the notable exceptions of Uranus and Venus, which got fucked by collisions).