When that space gas gets pulled together to form a star, the original gas and now a star their mass is the same (unchanged), but the size reduced, due to gravity. When the star collapses to be a black hole, again their mass the same but size shrunk, due to gravity.
It is not a valid way to ask in this manner:
So what stopped the space gas from forming a black hole in the first place?
The space gas does eventually shrink to become a black hole [if the initial mass is good enough for it to exist as a star then collapsed as a black hole], only the observer taking section by section of the whole process to observe [depends on which section is observed]. It's simple, when replace the object for analogy to this: heating the ice. Ice melts to become water, then gas. Now the OP is like asking: why ice doesn't turn to gas when heated but water? It sounds logical but in fact it is the construct of the words mystified a simple analogy.