Why is the Solar System Flat
As you move through secondary school science you slowly upgrade your models for how core concepts work. For instance the first model of an atom that you learn may be with a central nucleus surrounded by some number of electrons which circle around it.
Later you realise that there is no plane going on here. Instead the electrons can flow around in any direction and we get something properly 3D like this:
Later on in your physics education you realise that even this is far off from the reality. The electrons only exist in a superposition of all of their different possible states and it is only through observation that we can collapse the wavefunction and fix the position of an electron at one moment in time. You also have these fundamental particles act as waves. Science gets complicated if you zoom in too far.
I want to compare this building up of a model in my mind with an analogous system; that of solar systems. At primary school I saw the classic pictures of the planets (9 at the time because I'm an old person, but the demotion of Pluto was in 2006 so it's got to the point where a lot of my A level students won't remember Pluto as anything else) all neatly lined up in a line next to the sun.
Next I learned that the planets actually circled around the sun and that the distances between the planets were actually much larger than I had realised. At some point I had a thought that the situation with the planets might be just the same as the electrons in the second atom model. Why would the planets' orbits happen to line up if you just started them all off randomly?
However this thought was incorrect and of course the solar system isn't some spherical set up... mostly. The vast majority of the mass in the solar system is in the Sun (99.8%) with Jupiter making up almost half of what's left, and the vest of the planets and their satellites making up almost all of the rest. Asteroids, comets, bits of rock, ice and dust all make up tiny amounts of the overall mass despite how many of them there are.
The planets and the Sun are all within about 1 degree of the main plane of the solar system so there must be some physical reason for this. As the objects get smaller the angles get more erratic with Pluto reaching an eccentric 17 degrees off and the main part of the asteroid belt all lying within 20 degrees. Rogue asteroids can be found at any angle but at a decreasing frequency as you get further from the planets.
It turns out this is a consequence of the way solar systems are formed. We started off as a big cloud of gas. As gravity does its inevitable work the particles get closer together and form clusters. The biggest of these became the Sun, while others became the planets. Since the angular momentum of a system is conserved any spin that the original cloud had is still present in the much smaller system as everything crunched together.
One way to picture what is going on is to think about spinning around on a desk chair. As you move your legs and arms in, the total angular momentum is conserved and so you spin faster. This same thing happened with the dust cloud and its original axis of evolution is still that same as it always was. However the total energy of the system is also constant and that energy has to go somewhere. As particles bounce randomly around occasionally they bump into each other and cancel out their momentums. Over time this will happen to more and more of the particles moving up and down. However because the angular momentum is conserved the random movements around the great swirl of the system have fewer things to bounce into and so that motion remains.
The same situation happens on large scales with galaxies with most of them eventually forming a flat shape with a bulge in the middle a bit like a fried egg. Picture a lazy susan loaded up with 10cm of sand piled loosely on top. As it is spun you get the bits further out getting further out, while those near the centre remain piled high.
However, it is important to note that some spherical galaxies do exist. These occur when the original angular moment of the system was not particularly large.