Theoretically, planets would have an approximately equal chance of going one way in their orbit or another but in reality, this is not the case (at least in our solar system). Why is this?
The same reason (almost) all of them rotate in the same direction: because of the conservation of angular momentum.
Before a star and its planets exist, there’s just a cloud of disorganized gas and small molecules. The Solar System formed from such a cloud around 4.6 billion years ago.
On that scale, there is some small amount of rotation within the cloud. It could be caused by the gravity of nearby stellar objects, local differences in mass as the cloud churns, or even the impact of a distant supernova. The point is, all molecular clouds have at least a little rotation.
In a large system like a molecular cloud, each particle has some angular momentum, and it all adds together across a very wide area. That’s a lot of momentum, and it is conserved as the cloud continues to collapse under its own gravity. That angular momentum also flattens the cloud, which is the reason why the Solar System is near-planar.
When the cloud finally collapses, it forms a star and shortly after planets. However, angular momentum is always conserved. That's why planets all follow the same orbit, and why almost all of them rotate in the same direction. There's nothing to turn them the other direction, so they will continue spinning in the same direction as the original gas cloud.
There are a few exceptions, though. Whenever objects formed in such a way that sent them orbiting the opposite direction, they usually collided with objects going in the same direction as the original cloud. This destroyed any outlying objects or sent them in the same direction as the original cloud.
Still, two huge exceptions are planets Venus and Uranus. Uranus spins on an axis of almost 90-degrees (on its side). Venus meanwhile spins the opposite direction as Earth and the other planets.
In both cases there is strong evidence that these planets were struck by large objects at some point in the distant past. The impacts were large enough to overcome the angular momentum of the bodies, and give them a different spin. There are also a range of other theories; for example, some astronomers think that Venus may have been flipped upside-down. Point is, there were irregular events that happened to both of these planets.
Sir Cumference's answer is great. Molecular clouds are generally thousands of times more massive than the Solar System, and since they're less dense they're much much larger in volume.
We don't know where our Solar System originated from, and we don't know how many other stars were born in the same cloud, probably hundreds or even thousands (just recently 1 or 2 stars were suggested to be sisters of Sol, but the jury is, as far as I know, still out on that).
Anyway, either due to interstellar winds, magnetic fields, supernovae explosions, or some other difference in average density, a volume of our mother molecular cloud began to collapse due to gravity being just a bit more in some areas.
The more the cloud became concentrated, the more the gravitational attraction increased, so the faster it collapsed. While dust and gas collide, the whole system conserves energy and momentum (as it is an isolated system) , and thus is naïve to assume that planet orbits should be random — which means any which way, you seem to have assumed that space is two dimensional, and the most random arrangement would be a flat disk.
Nope. It would be a sphere... like a swarm of flies around something stinky. When we program a computer to model a swarm of random dust and gas collapsing, it turns out that due to chance it will select a preferred direction. A random dust cloud will collapse into a disk with most of the particles orbiting in the same direction (this ignores possible effects from the Milky Way influencing the process, so even without the molecular cloud orbiting the center of the Milky Way, disk formation will occur).
Keep in mind that these answers are tentative: most of the gravity in the Milky Way is of dark matter, and we're still working on understanding how that influences star formation and until we know a lot more about dark matter, we can't be sure our computer models are correct. Generally, we prefer models that give results similar to the actual way our Solar System is.
But guess what? The thousands of exoplanets we've discovered have far more "hot Jupiters" (gas giants very close to their stars) than we expected. So we are adjusting our models. One popular idea is that planets had a lot more collisions than we used to think. This means more planets in very close to the Star, and more planets actually ejected from the star system. Who knows, perhaps that's where Theia came from.