Galaxies have five components: the nucleus, bulge, disk, spiral arms, and halo. The nucleus is the center of a galaxy, which contains a black hole. The bulge is present in some galaxies. It is a dense region. The disk is flattened and rotates within a galaxy. The disk is where most stars and gas are located. The spiral arms are the spiral patterns. Lastly, the halo is a spherical component that holds stars, gas, and dark matter.
Galaxies are composed of billions of stars, gas, and dust. Gas and dust are the raw materials that play a role in star formation, and dark matter makes up the majority of the mass present in galaxies.
Galaxies began to form when vast clouds of gas and dark matter collapsed under gravity.
Dark matter, considered hypothetical matter, doesn't interact with light. While it doesn't interact with light, its gravitational influence plays a huge part in the formation of galaxies. It influences the motions of the stars and gas within a galaxy. Dark energy expands the universe quickly and pulls galaxies apart.