The Earth loses free hydrogen because, I think, the speed of movement of hydrogen molecules is greater than the escape velocity.
So how does a cloud of hydrogen ever become so dense as to form a gas planet or even a star? Of course in space it is colder but equally as clouds colllapse they will warm up, and so lose hydrogen. I heard on a TV program that a supernova will cause new stars to form but they seem a bit too rare to me. I would be grateful if someone could point me in the right direction to find out.