How did gas giant planets form?
We don't actually know how gas giants are formed.
First of all the term gas giant is misleading. The term gas giant refers to a planet which is predominantly hydrogen and helium. Only Jupiter and Saturn are true gas giants. Even so the pressures at the centres of these planets are so high that even hydrogen will be solid.
Uranus and Neptune are made of heavier compounds which are referred to as ices. So they are really ice giants.
We have never observed the formation of gas giants so we have to rely on theories and computer simulations.
The long standing theory is that a rocky core which gather in gaseous material to for the gas giant. The problem with this is that simulations predict that this process would take too long and the necessary gas would have dissipated before the planet could form.
There are now theories that gas in the disc of material which formed the solar system clumped together and gas giants were formed very quickly.