Helium is the second lightest gas in the universe.
Hydrogen’s the lightest. Both gases have mass and therefore weight.
It just so happens that they weigh less than air. Because of that, the heavier air sinks below them, pushing them upward— much in the same way that water flows below Styrofoam and pushes it toward the surface.
If released into the air, helium and hydrogen atoms will rise up toward the top of the earth’s atmosphere.
If captured inside a balloon, the gas will do the same.