> I don't understand the question. There must have been a cloud of gas big and dense enough to provide the mass for the solar system. Once that exists gravity does the rest, right?

Very large clouds of gas can exist with gravitation attraction balanced by gas pressure. This delicate balance can be disturbed by passing stars, supernovae, galactic mergers and other events.