It’s relatively easy for galaxies to make stars. Start out with a bunch of random blobs of gas and dust. Typically those blobs will be pretty warm. To turn them into stars, you have to cool them off. By dumping all their heat in the form of radiation, they can compress. Dump more heat, compress more. Repeat for a million years or so.
Eventually pieces of the gas cloud shrink and shrink, compressing themselves into a tight little knots. If the densities inside those knots get high enough, they trigger nuclear fusion and voila: stars are born.