Those elegant spiral arms are not what they look like. The bright curves in a spiral galaxy are not fixed swirls of stars but patterns in a rotating disk where the material moves through at different speeds, a problem known in galactic dynamics as differential rotation.
The real trick is that the arm is a density wave. Stars and gas orbit the galactic center on nearly Keplerian paths, yet the spiral pattern itself rotates with its own pattern speed, slower than most of the material inside it. As stars pass through the denser region, they crowd together, light up, and then drift out again, much like cars bunching up in a traffic jam that stays put while individual cars move on.
This density wave is sustained by self-gravity and by gravitational instability in the rotating disk, which allows small perturbations to amplify into a coherent spiral pattern instead of being sheared into featureless haze. Gas clouds entering the wave compress, trigger star formation, and the short-lived massive stars make the arm stand out, even though those stars do not stay in it for long. The arm is a moving pattern, not a permanent structure of the same stars.