Answer:
Step-by-step explanation:
Mass accumulates. Two rocks hit each other in space, and a little bit of rock "A" sticks to rock "B". This happens again and again..sooner or later, rock "B" has enough mass so that its gravity is now stronger than any other mass within shouting distance, so as rocks get closer to it, they tend to smash in to the big rock rather than fly off into space...given enough time, you get a rocky old planet like Earth. The gravity even affect atomic particles..so you get some H and a couple of O's and before you know it, you got water. The same basic thing works with gaseous planets, except that they don't collect rocks, they collect gas.