Someone fact-check me, but I'm pretty sure that there is two reasons for it. The first reason as to why all the planets are spinning in the same direction is because when the planets formed there were different planets, or basically small rocks that were going in different directions, but all the different direction ones hit each other and eventually one direction that had more planets became the only direction.
as to why the direction is not up and down, it doesn't really make sense in space as there is no up and down but there is the direction that the Sun is moving in throughout the galaxy and if that direction is up then the planets are going on the sides and not up and down and that makes sense because the Sun is pulling all of the planets in that direction, so they are dragging along, so they can't spin in front of it and then behind it.
EDIT:
The reason all of the planets are spinning in the same direction is not what I wrote. It's actually about the fact that they all formed from a single gas disk. So they all formed from a disk that was spinning in a single direction. The collisions actually contributed to the growth of the planets and less so to their direction.
I want consistency 😤