Why are some galaxies flat? 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 :) )
 A: 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.
A: 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.
A: 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...

However, the story can be different for gas. Gas is interacting,
  unlike dark matter and stars. This means that it has a way to get rid
  of energy -- particles can collide, excite electrons, which later
  de-excite and turn that initial kinetic energy into light. This is how
  a gas cools. Gas can lose energy, but angular momentum is extremely
  difficult to get rid of. If a galaxy merger is gas-rich, and has a lot
  of angular momentum (which just depends on the initial conditions),
  there can be a lot of bulk rotation to the gas. As the gas cools
  (which the stars and dark matter can not, since they are
  non-interacting) and loses energy, it collapses into a disk. This is a
  lower energy configuration.
Earlier, I claimed that stars are basically non-interacting and won't
  collapse to a disk, in the same way that dark matter won't collapse.
  But even earlier, I said that stars are different from dark matter.
  This difference is that stars are born in gas clouds, so they trace
  the distribution of (molecular) gas in a galaxy.

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/

To reduce the kinetic energy of the system, you want the particles to
  lose as much speed as possible. The gas and stars in a sphere have
  upwards and downwards motion, inwards and outwards motion, and
  circular motion. You can't get rid of the circular motion, because
  angular momentum is conserved. Once you get reduce these motions,
  everything will be going in nice circular orbits.
But why are all these circular orbits in the same plane? Well, you
  also want to reduce the potential energy. The closer particles are to
  each other, the lower their gravitational potential.
A disc is the closest you can get these particles to each other while
  still keeping them in circular orbits (as required by conservation of
  angular momentum).

A: 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.
