Astronomers do not know, exactly. We have never seen a close-up image of a baby globular cluster, but there are some things that seem to stand out about these systems and what we do see in deep space, especially with the Hubble Space Telescope.
Galaxies are flat because the material which is forming stars, or has formed stars in the past, had a lot of angular momentum. The more angular momentum, the flatter the system. Also, the systems we see with very little angular momentum, such as elliptical galaxies and globular clusters, have very old stars, so the connection seems to be that if matter has little angular momentum, it is an easy and quick process to form stars. If it has lots of angular momentum, it is harder and slower to form stars. Elliptical galaxies formed all of their stars in one great 'burst' of star forming activity when the universe was very young. These bursts lasted, perhaps, only a few hundred million years, during which time 100 billion to 1 trillion stars were formed, along with some very massive ones that later became supernovae. Spiral galaxies, which have lots of angular momentum, have dragged out their star-making activity over 10 to 15 billion years.
The Hubble Space Telescope recently looked at a galaxy called NGC 1275 which has undergone a collision with a neighbor, and discovered what astronomers later described as baby globular clusters. Unfortunately, the images could not make out individual stars from this distance. The striking thing is the shear number of stars that must have formed in several dozen of these proto-globular clusters, during a violent collision between two galaxies. These clusters are only a few million years old, again attesting to how quickly stars can form in large numbers if some unknown conditions are just right. What these conditions are for globular clusters is still a mystery.
So, we think the rule of thumb is that globular systems of stars have little angular momentum and had an early burst of star forming activity. Flattened star systems such as spiral galaxies managed to acquire lots of angular momentum and their star forming activity is much more sluggish and spread out over billions of years. Again Hubble photographs show that many galaxies grow by eating their neighbors, and very simple computer simulations of these events always show angular momentum being transferred into the final system from the orbital dynamics of the collision. Perhaps all spiral galaxies get their angular momentum in this way.