to answer this is that the disturbance near a cloud, such as the explosion of a star, causes the dust and particles to spiral and come closer due to centripetal force. Moreover, the mass of the particles bring them closer due to gravitational force. Therefore, the main governing forces in the formation of a nebula are gravitational force and centripetal force.
I hope this helped :)