I always see pictures of the solar system where our sun is in the middle and the planets surround the sun. All these planets move on orbits on the same layer. Why?
We haven't ironed out all the details about how planets form, but they almost certainly form from a disk of material around a young star. Because the disk lies in a single plane, the planets are broadly in that plane too.
But I'm just deferring the question. Why should a disk form around a young star? While the star is forming, there's a lot of gas and dust falling onto it. This material has angular momentum, so it swirls around the central object (i.e. the star) and the flow collides with itself. The collisions cancel out the angular momentum in what becomes the vertical direction and smear the material out in the horizontal direction, leading to a disk. Eventually, this disk fragments and forms planets. Like I said, the details aren't well understood, but we're pretty sure about the disk part, and that's why the planets are co-planar.