Scientists believe galaxies form in one of two ways: superheated gas collapses upon itself to form huge clumps of stellar material before merging with other clumps to form galaxies, or clumps of superheated gas are the size of dozens of galaxies before breaking apart into smaller units. There are more than 100 billion galaxies of varying sizes, according to How Stuff Works.
Most protogalaxies first formed nearly 14 billion years ago with the Big Bang, when hydrogen coalesced at the center and dark matter fanned out around the edges of galaxies. The basic units of galaxies are stars and star clusters. Stars clump together in clusters based upon their ages. These star clusters then form galaxies.
Scientists identify elliptical and spiral galaxies as the two main types. Elliptical varieties are similar to Earth's solar system in that all the stars form at once and retain a relatively spherical shape. Spiral types occur when stars form at different times and gravitational forces move stars into a rotating disc. About two-thirds of all observed galaxies are spiral shaped. Some types have unusual shapes, such as toothpicks or rings. When galaxies merge, astronomers believe the resulting galaxy always forms into the elliptical variety.