Dipole moment is a vector quantity and is equal to charge multiplied by distance. When a molecule is symmetrical (repeat its face when rotated at 180°) then the dipole moments present in it will cancel out each other making the molecule non polar. In given examples,
CO₂ has zero dipole moment as it has linear structure and both dipoles cancel out each other.
CH₄ has a symmetrical Tetrahedral structure, it also cancel out all dipole moments making the molecule non polar with zero dipole moment.
H₂S has a bent structure and a dipole moment of 0.95 D. As the sulfur contains 2 lone pair of electrons, so lone pair of electrons contribute in dipole moment.
F₂ is also non polar and symmetrical, so the net dipole moment of this molecule is zero.