First, the planets which formed at distances far enough from their stellar nucleus to become cool enough to capture hydrogen.
The planers were cool enough to capture hydrogen.