How are gaseous planets formed?
By accretion under gravitational attraction, but with greater mass than rocky planets.
Gas giants are formed in basically the same way as rocky planets - that is accretion by gravitational attraction from a disc of gas and dust left over from the formation of a star.
The thing that causes large planets to be gaseous is their mass. Beyond a certain mass, the forming planet with stronger gravity is able to retain more of its atmosphere against being stripped off by the solar wind.
Beyond about 13 times the mass of Jupiter, such bodies are classified as brown dwarfs instead of planets. Heavier still and the density can become high enough to start hydrogen fusion and form a star.