The best way to understand geometry is by drawing the Lewis dot structure of the molecules.

The geometry of CO2 is linear (electron geometry is linear too) because the two bonds are the farthest apart and the bond angle is 180°. This is what makes of CO2 a non polar molecule because the dipole moments of both bonds cancel out.
The geometry of SO2 is bent (electron geometry is trigonal planar) because the lone pair on the central sulphur atom pushes the two bonds down for a bond angle of 120° due to the electrons repulsion. This is what makes of SO2. a polar molecule because the dipole moments of both bonds do not cancel out, and the molecule will have a net dipole moment.