Thank you for the opportunity to help you with your question!
Sulfur has six valence electrons, while carbon only has four.
Lewis structure of SO2 has two bonds between the O and S that have bond orders of about 1.5 due to the the delocalized pi-bonding. This can't be shown with a Lewis diagram, therefore the older idea of "resonance" is used:
O-S=O <--> O=S-O
Either way, a lone pair on the sulfur makes the molecule bent at approximately 120 degrees. Sulfur has sp2 hybridization.
Carbon dioxide on the other hand usually written with two double bond and since it has no lone pairs on the carbon, the molecule is linear. Carbon exhibits sp2 hybridization.
Carbon has 4 valence electrons. Sulfur has 6.
Carbon, therefore , needs 4 more electrons to fill its outer shell. Sulfur needs 2.
Furthermore, carbon has 2 valence electrons that are not paired. Sulfur also has 2 unpaired valence electrons.
Looking at their valences, we can see that carbon's unpaired electrons are at the beginning of the P orbital, while sulfur's is at the end.
This means that if carbon bonds with oxygen, the electron pairs will "balance" each other out. However, sulfur's electron pair in the P orbital is more stable than any bond it will form with oxygen. This pair will stay on one side of the sulfur atom, which leaves the oxygen atoms no choice but to be pushed to the sides, therefore SO2 is not linear.
Content will be erased after question is completed.