The correct role of gravity in the formation of the planets is that gravitational forces brought together several moon-sized bodies, called planetesimals, to form larger bodies that became planets.
During the early stages of the solar system's formation, dust and gas in the protoplanetary disk coalesced under the influence of gravity. These small particles formed larger bodies, known as planetesimals, which collided and merged over time to create protoplanets. Through continued accumulation of material and gravitational attraction, these protoplanets grew into the planets we see today. Gravity was crucial in this process, as it facilitated the attraction and merging of matter in the disk surrounding the young Sun.