First of all, it must be stated that most triatomic molecules are either linear or bent. This depends on the electron geometry of the molecule and the number of bonding groups, multiple bonds and lone pairs present.
CO2 contains four regions of electron density and two bonding groups. For a specie containing two bonding groups, a linear molecular geometry is expected with an angle of 180°.
For a specie having two bonding groups and no lone pairs with multiple bonds, the expected electron geometry is also linear.