There are #4(C)+2xx6(O)##"valence electrons"# to distribute around the 3 centres. As is typical, the least electronegative atom (carbon) is placed in the middle, and thus,
#O=C=O#, from left to right there are #"6, 4, and 6 valence electrons"# associated with each atom.
The central carbon is #sp-"hydridized"#, the oxygen atoms are #sp^(2)-"hybridized"#. The #CO_2# molecule is thus LINEAR with #/_O-C-O=180^@#.