How were the gas giants formed in comparison to the rocky planets?
Newtonian physics shows us that when objects are in motion/orbit, the heavier particles tend to stay close to the center of gravity while the lighter particles move outward. The gas giants are made up mostly of hydrogen, methane and ammonia, all of which are very light in comparison to the rocky particles the inner planets collected. As these gases collected around a central point of gravity, the gas giants were formed.
In the early solar system there was a disk of material orbiting the Sun. The material consisted of dust ices and gasses.
The solids started to lump together to for a protoplanetary disk. The clumping together process continued until there was just one planet in the orbit maybe with moons.
In the inner solar system, volatile materials were gasses and didn't take part in the clumping process. Hence the inner planets are rocky planets.
Further out the volatile materials and gasses were cold enough to be solid. This led to the formation of the gas and ice giant planets via the clumping process