What is the explanation for the flatness of some galaxies?
(If it's due to their rotation then why they are rotating, why some other galaxies are not flat etc., I would like to hear a nice and complete answer :) )
One interesting fact is that there are some revolving structures in space that aren't mostly flat - they're known as elliptical galaxies. And the difference here is that elliptical galaxies usually don't have much gas or dust in them. Interestingly enough, the orbits of objects in the inner solar system also tend to be coplanar, whereas the orbits of the minor planets in the outer solar system tend to be more inclined (or non-coplanar)- the difference here, again, is that there was less gas and dust in outer solar system (back during the era of accretion, and still true today)
So, back to the original question. When there's lots of dust in a galaxy, the galaxy tends to collapse into the planar shape of a spiral galaxy (to maintain angular momentum and to minimize gravitational potential energy). Which is the same thing that happens in the inner solar system.
And why does that happen? Well, we first go into the answer here: http://www.quora.com/Astronomy/Why-are-some-galaxies-disk-shaped-and-not-spherical. As Leo C. Stein explains...
So then, how is this a lower energy configuration? Well, we go into a Reddit AskScience thread, and use Astrokiwi's nice explanation at http://www.reddit.com/r/askscience/comments/ik4jj/during_spiral_galaxy_formation_how_does_gas/
The degree of flattening of a galaxy has to do with velocdad rotation co. the higher the rotational speed thereof, the greater the flattening.
This can be evident when contrasted with the different rotation speeds of galaxies as a function of flattening. You will see that there is a direct relationship.
If you are interested there is a PDF download here.
I would say it largely has to do with the gas content of the galaxy. If the galaxy has nontrivial net angular momentum, then various drag forces acting on the gas component tend to make the gas concentrate onto a plane which is perpendicular to the angular momemntum vector. New star formation happens only where the gas is present, and since heavy starts are thousands to millions of times more luminous tahn lightweight stars, they contribute much of the visible light. These very bright massive stars don't live enough to wonder far from the points of origins (in molecular gas clouds), and hence they trace out the gas disk. These flat (usually spiral) galaxies usually have a population of older stars whose distribution is roughly speherically symmetric. But if star formation is rapid enough the young bright new stars that trace out the gas disk dominate the visual appearance.
The answer to your first question is just what you guessed: rotation.
The flat (e.g., spiral) galaxies tend do be rotating, whereas the less flat ones (e.g., ellipticals) tend not to be. Conservation of angular momentum lets the rotating ones collapse along the direction of the rotation axis but not the other directions.
When you try to go further and examine why some galaxies end up one way and some end up another, I think @Willie Wong's comment is right: this turns into an astronomy question rather than a physics question. You're likely to get better answers if you ask in the astronomy stack exchange.
Thank you for your interest in this question.
Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.
Would you like to answer one of these unanswered questions instead?