The preferred model for the Solar system formation is called the Condensation theory
, an improvement over the old Nebular theory. Quoting from this page:
"An advanced theory, called the condensation theory, includes the nebular theory but also incorporates interstellar dust as an essential ingredient in the formation of the planets. This theory claims that the dust grains of the interstellar medium helped cool the nebular cloud by radiating heat away, and also acted as a foundation upon which atoms could attach. These properties of the interstellar dust grains aided in the collapse of the nebula and in the formation of planets"
So why are outer planets gaseous and inner rocky in the solar system? It seems that is a question of temperature. Inner planets are closer to their sun, this extra heat seems that can dissipate the gas around these bodies when they were protoplanets. the same page explains it this way:
"Another factor in the development of the four inner terrestrial planets and the outer gaseous planets was temperature. After the protoplanets had formed, the central regions of the solar nebula were collapsing and forming the Sun, as described in Module 2. The young Sun caused the temperature of the closer inner protoplanets to be higher than the outer protoplanets. As a result, the kinetic energy of the gaseous molecules was too high for them to coalesce, and they simply dissipated. At the outer planets, however, the molecules were cold, and were moving slowly enough for gravity to overcome their movement. Over the course of several million years, the planets grew into the planets we know today. "