If the cloud had enough angular momentum when it started, it would rotate as it collapsed, spinning up and flattening out. Just like we've seen before in the formation of the solar system. The cloud with large enough angular momentum would become a spiral galaxy. Those with less or no angular momentum would become ellipticals. The density of the cloud itself determines whether the galaxies forming from it are mostly ellipticals or spirals.
Elliptical galaxies are more common in large clusters of galaxies than spirals are.
The cloud that became a cluster was probably denser initially. No star-formation going on even back then in elliptical galaxies. This means that star-formation ended for elliptical galaxies even when they were very young. Other evidence around but too much to go into. The complication is that galaxies interact .