Why are our planets and galaxy in a plane shape?

Why are the planets in our solar system spread out in a plane instead of being more randomly spread around the Sun? And why is our galaxy in the shape of a plane instead of all the stars in our galaxy being more randomly spread around the middle of our galaxy?

As Space Tiger explained in a different thread, a disk is the most 'economical' shape for conservation of angular momentum in a rotating mass. When the initial gas cloud was coalescing, therefore, it would naturally settle in that way.

Keep in mind that we still don't have a complete understanding of the formation of real disk systems, but it's best just to think of these as "minimum energy conditions". With no angular momentum or with collisionless particles, you will tend to get a sphere. With heavily interacting particles that have a lot of angular momentum, you tend to get disks.

Thanks yet again, Mr. Tiger, for setting things straight. While astrophysics is one of my favourite things in life, I really have no education at all in it. It's always a pleasure to read your posts and further my knowledge. Cheers, bud.
edit: So what happened to my edit in the previous post where I said that ST's explanation was better?