First of all, polarity refers to separation of charges in a molecule; or the existence of partial charges in the overall structure of a molecule. Polarity of a molecule primarily results from two things:
1. Difference in electronegativity of bonded species. The higher the difference between the electronegativities of the bonded atoms, the more polar their bond gets. In the case of water, this bond would be the O-H bonds, and in carbon dioxide, this would be the C=O bonds. Both of these bonds are polar due to the difference in electronegativity of O and H, and of C and O (O being more electronegative, and hence has the tendency to pull the electrons closer to its nucleus).
2. Assymetry of the molecule. Even though there is difference in the electronegativity of bonded atoms, the resulting molecule may not be polar if the entire molecule is symmetric. This can be explained by looking at the forces as vectors, and performing vector addition. Let's try to compare the structure of water and carbon dioxide. Water is a bent molecule due to the lone pairs present in oxygen. On the other hand, carbon dioxide is linear. In carbon dioxide, the carbon is flanked by the oxygen atoms ( O=C=O). Each C=O bond is polar with O pulling the electrons towards itself. Since you have to identical AND opposing forces, the effects cancel, and the result is a non polar molecule of carbon dioxide. The same cannot be said with the bent molecule of water. The forces do not cancel because water is not a symmetric molecule.
In summary, polarity of individual bonds do not relate to the polarity of the entire molecule. The polarity of individual bonds is necessary for a molecule to be polar, but it is not a sufficient reason. The molecule must also be assymetric (since symmetry might 'cancel' the effects of the polar bonds).
You need to look at the molecular geometry of both the molecules.
Carbon is bonded to two oxygen atoms with double bonds. All four of carbon's valence electrons are shared with oxygen's. There are no lone pairs on the central atom. Therefore, CO2 has two electron domains and has a linear shape.
Meanwhile, the oxygen atom is bonded to the hydrogen atoms with single bonds. While both of oxygen's unpaired electrons become paired with hydrogen's valence electrons, it also has two lone pairs of electrons. There are a total of four electron domains and H2O has a bent shape.
CO2 has molecular symmetry, while H2O does not due to its lone pairs of electrons. I have linked a picture of their Lewis Dot Structures if you need to see it visually.