Stars beyond counting populate the universe. Most reside in dense groups known as galaxies. These 'island universes' come in many shapes and sizes, and contain anywhere from a few million stars to a trillion or more. Some are still churning out lots of new stars, while others are quietly living out their lives. And some galaxies are merging to form even bigger cities of stars.
Astronomer Edwin Hubble was studying an object in the autumn constellation Andromeda known as the Andromeda Nebula. Viewed through a telescope, it looks like a pinwheel, with bright streamers wrapping around a big bulge in the middle. At the time, most astronomers thought the Andromeda Nebula and similar objects were bright pockets of matter inside the Milky Way.
But on October 6, 1923, Hubble noticed a particular type of star inside the Andromeda Nebula (M31). Hubble realized that the star was a Cepheid variable, a type of star that astronomers use to measure distances in the universe.
Hubble found that this Cepheid -- as well as others that he saw on other photographs -- was far outside the Milky Way. When Hubble reported his findings the following year, astronomers realized that they had misnamed the Andromeda Nebula. It's not a nebula at all. Instead, it's a galaxy -- the first confirmed "city of stars" beyond the Milky Way.
In the decades since Hubble's discovery, astronomers have found that galaxies come in many shapes, sizes, and colors. Like the Andromeda galaxy and our own Milky Way, many are spiral shaped. Others look more like footballs, and still others have no regular form at all. The universe may contain 100 billion galaxies or more.
The smallest galaxies contain only a million stars or so. The Milky Way is home to several hundred billion stars. And the largest galaxies contain more than one trillion stars. Galaxies also contain vast clouds of gas and dust, which are the raw materials for new stars.
Galaxies also contain vast quantities of "dark matter" -- matter that produces no detectable light or other form of energy, but that reveals its presence through its gravitational pull on the visible stars and gas. In the Milky Way, dark matter appears to account for more than 90 percent of the galaxy's total mass. Most of the dark matter resides in a "halo" that surrounds the galaxy's bright disk and extends hundreds of thousands of light-years into space.
Galaxies are sprinkled throughout the universe. Only three galaxies outside the Milky Way are easily visible to the unaided eye -- the great galaxy in Andromeda (the Andromeda Nebula) and the Large and Small Magellanic Clouds. These are some of our nearest galactic neighbors. The farthest galaxies ever observed are more than 10 billion light-years away. These galaxies formed soon after the universe itself was born.
In theory, if the universe lasts long enough, the galaxies will die. Their stars will burn out. Some of the stars will drift away, but some will fall into giant "black holes" that lurk in the hearts of most galaxies. Eventually, all galaxies will disappear from sight.
Reference
https://stardate.org/astro-guide/galaxies-cities-stars