No contradiction, because time dilation and length contraction, even if dilating and contracting, are working in the same sense:
For this purpose I recommend to use an example which is simpler than yours (I think it is not useful to consider the light ray beside O and O'. If you are asking a question try first to reduce it as much as possible).
Example: A spaceship is travelling near light speed at 0,99 c from Earth to an Exoplanet 100 light years away (Earth coordinates). The Lorentz factor γ for 0,99c is 7,09. For the spaceship, due to length contraction (with division by the Lorentz factor) the distance is reduced to 14,10 light years (spaceship coordinates). At a speed of 0,99c, the travel will take the spaceship 14,24 years (spaceship coordinates).
And it is only now that we apply time dilation: For the observers (on Earth), the time of the spaceship clock (14,24 years) has to be multiplied with 7,09, giving 101 years.
Now look how exactly time dilation and length contraction were applied:
Length contraction is the contraction of the proper distance (Earth frame) as observed by the spaceship (spaceship frame).
Time dilation is the dilation of proper time (space ship frame) as observed by Earth (Earth frame).
We used the proper distance in Earth coordinates and proper time in spaceship coordinates. If you want you can say that in this example time and space are both contracted for the spaceship, and they are both dilated for Earth.