Why CO2 has 4 vibrational degrees of freedom? If I have a diatomic molecule, so a linear molecule, $3N-5=6-5=1$ holds, since this vibrational degree of freedom corresponds to the stretching coordinate beetwen the two nuclei.

If I consider water for example, I have a nonlinear triatomic molecule, so the formula says $3N-6=9-6=3$ vibrational degrees of freedom. Also in this case it makes sense since they correspond to the bending angle and to the $2$ stretching lenghts.

While, If I consider $\ce{CO2}$, in this case I have a triatomic linear molecule, so $3N-5=9-5=4$ vibrational degrees of freedom. Of course $2$ of these correspond to the two stretching lenghts, but I really don't understand what the other two correspond to. Since the molecule is linear, there shouldn't be angle to consider, otherwise it would not be linear anymore.
Molecular vibrations can certainly occur by changing the O-C-O bond angle away from 180º. When we call the molecule linear we are saying that the geometric minimum is a linear configuration; however, vibrational modes can (and do) break that symmetry. What's important is that the average nuclear position is a linear molecule (or if you're doing a geometry calculation you would say that it's the 0 K positions). 

So the two vibrational modes you're missing are the two O-C-O bends at 90º from each other. 

Also as a note: you seem to be suggesting that the two stretches correspond with the two bonds stretching. That's not quite true. One of them corresponds to both C-O bonds stretching outward at the same time (in phase) and the other will correspond one compressing while the other stretches (out of phase).

For a full derivation of the normal modes of CO$_2$ there are many sites, but this one looked good: http://www.colby.edu/chemistry/PChem/notes/NormalModesText.pdf