What is it that makes a galaxy form into a spiral or an elliptical shape?
Gravity is the main factor in the formation of galaxies. It causes gas to collapse into stars, and stars to clump together in galaxies. I think you are asking about how the different shaped galaxies are formed. Barred or spiral galaxies seem to be the norm in the universe. Gas and stars are attracted into a cloud by gravity. As it condenses, it begins to rotate one way or the other due to the average relative motion of gas and stars. Stars and gas clump together locally to create the arms. About 10% to 15% of galaxies appear to be elliptical with few identifiable arms. There are several theories about their formation. Most elliptical galaxies are missing major gas clouds of spiral galaxies. This suggests that these galaxies are older, and may be what spiral galaxies look like after billions of years. Elliptical galaxies are most often found near the core of galaxy clusters. The motion and gravity of other galaxies in the cluster may have distorted a spiral galaxy into an elliptical sha