system
Given the following post, respond as if you're commenting on Reddit:
human
Why are there spiral galaxies?

Shouldn't they all be elliptical because objects orbiting closer to the center of the galaxy move faster and pass up the stars on the end of an arm.
gpt
Most galaxies are formed as disks out of massive gas clouds. These gas clouds have some angular momentum (asking why they are endowed with some spin is a whole other question, one that is be happy to answer...). As the gas cools through a process called "atomic line cooling", the gas generally doesn't want to lose that angular momentum, even though it's being sucked in by gravity. As a result the spinning gas cloud ends up getting flatter. This flattening is a bit of a runaway process as it causes more gravitational pull towards the disk compared with towards the center. As the gas cools more and more the galaxy ends up as a rotating disc. 

The spiral arms (and sometimes a bar in the middle) form as a second step due to small density perturbations in the disk. The spiral arms are actually a density wave in the disk. Consider a highway with one lane in each direction. Now imagine a slowly moving truck on one lane (our density perturbation). Cars behind it will get stuck as they need to wait to over take it. As a result you get a higher density of cars behind the truck compared with ahead of it. That's basically what a spiral arm is - a build of stars and gas clouds trying to overtake a transient gravitational sink - and also incidentally why you have stars forming in the spiral arm. The increased density compresses galactic gas causing them to spawn stars.