How can bits of dust and ice and gobs of gas came together to form the planets without the sun devouring them all ?
Has to do with the rotational energy of the system.
Anything not spinning fast enough around the centre of mass of the system, ends up in the sun (the vast bulk of the total mass – only a very tiny fraction fell into the planet zone band of energies).
Anything spinning too fast ends up elsewhere in the universe.
Stuff spinning with the band of energies in between those limits settles into orbits and gradually clumps together to form bigger bits (planets).
And there are so many different variations on themes happening, with stuff bumping into other stuff and shifting orbits, etc.
And you need to keep in mind that all the stuff that went into forming our solar system appears to be leftover matter from an earlier generation star that exploded in a supernova. The original mass of the universe seems to have consisted mostly of hydrogen, with a little helium, and tiny traces of lithium. All the heavier elements could only form within the nucleus of massive stars, and can only get out into the universe at large when those stars exploded.
So it seems clear that we are made of recycled star stuff, second generation matter.
Yep, gravity is a part of clumping, as is stickiness, as is light pressure. They all have significant roles.
We are getting into details that are very context sensitive, and can be quite counter intuitive.
Stickiness is just that what it seems, a shorthand notation for the tendency of different sorts of matter to be able to attach to each other.
Electric charge is a repulsive force (if all particles have the same charge) that is vastly stronger than gravity).
Once a sun starts shining, and emitting a stream of charged particles, then small particles can’t stick to each other very often, they are repelled by their static electric charge.
Similarly with respect to light. Small irregular particle tend to start spinning under the asymmetric forces of the pressure of light.
So there is a window of opportunity for stuff to start clumping together under gravity to form smallish objects like rocks and planets, that needs to occur before enough matter gets together in the central area to generate enough pressure and temperature for thermonuclear processes to start generating vast amounts of light and heat.
So, like I said – the details are complex. Scale and timing are important factors – as with most things in existence (at some level).