There is, however, a significant difference between the contraction of the stars of a cluster from the original gas cloud, and the contraction of whole galaxies from the supercloud that gives rise to a group or galaxies. While the stellar cluster cloud fragments into stars, the turbulence in the contracting supercloud fragments it into pieces which themselves are further subdivided, and galaxies are formed by the gradual attachment of smaller pieces to one another. The rotational property of the Galaxy is explained by the original relative motions of the constituent pieces, and the more compact the Galaxy became, the more marked would be the effect of its original angular momentum; the flatness of the disc is a result of this rotation.
Source: wiktionary