The question is perhaps more a matter of why are most galaxies rotating enough that that overall rotation dominates the equilibrium and thus shape.
A galaxy need not rotate enough for this to be, but most do.
The question is perhaps best addressed by looking at the very early universe. We tend to assume that the net rotational moment of the universe is zero. But even in the very young universe things were far from a stable expanding equilibrium. The favourite example of the fingerprint of this is the inhomogeneity of the cosmic microwave background. Even the tiny variations there cascade into further inhomogeneities.
Look at two streams of water merging and look at the vortices being created. Ask yourself “why do they rotate?” Same question. Those vortices themselves create even smaller vortices and they get shed out into the evolving system. Here again the net angular moment was zero, and remains so, but that is found by summing across all the individual whirling structures. So to we assume the universe evolved. Huge swirling clouds of matter filled an expanding universe. As things settled down and the universe grew, gravitational attraction would hold together lumps of swirling stuff, and slowly these would condense down into structures from which galaxies would form. At the large scale we see a universe filled with threads of matter, where each thread is itself comprised of chains of whirling clusters of galaxies. And within those clusters galaxies themselves were pulled together from the whirling gas clouds. So they started life as distinct entities with a net angular moment. Some with more than others. But it seems the dynamics of the systems tends to favour the mix we see.
Probably another aspect about what we see in galaxies is the distinction between ordinary matter and dark matter. Ordinary stuff interacts with itself, strong, weak, and electromagnetic forces. That means it clumps. This is a really big deal. If this was not so even stars would not form. Clouds get pulled together by gravity, but gravity isn’t strong enough to hold stuff together enough to allow really dense accretions of matter to occur. Clumping gets us bigger accretions of stuff, and from that we birth stars. They are born, burn, burn out, go out with a bang, and generate more useful matter, and the cycle goes on, with clouds of matter from which we get not just stars but planets. All this matter is swirling about, and any given accretion of stuff is likely as not to have a rotational moment. So we get plants that orbit their suns, rotating suns, all living within a rotating galaxy, that iself lives within a cluster of galaxies that is itself rotating. Add all the rotations up and you should sum to zero across the universe. But locally, things spin.
Dark matter doesn’t clump, and that probably provides the clue about why it doesn’t manage to spin down into a disk. As @md-2000 painted a neat picture of, clumped up lumps of matter will interact as separate bodies, all exchanging momentum with one another as they whip about. Eventually settling into some pattern dominated by the overall angular moment. I suspect that the lack of such activity in the clouds of dark matter is why they remain as a diffuse bubble around the galaxies.
There may well be a point where a proto-galaxy is rotating too much to be able to hold together, and this provides a cut off point beyond which you don’t get a galaxy, and thus why there is a favoured shape. Back when it was all whirling vortices there was a maximum vorticity and spin for a bubble of matter, and if that was exceeded it broke up into smaller stable vortices. Totally guessing here. But it seems reasonable. This is the sort of thing that the computational cosmologists like to play with. Then again, as I like to joke, cosmology is the only science where the error bars are on the exponent.