So I know the equations of time dilation and length contraction given by: $$L' =\frac{1}{\gamma}L_0$$ $$t' = \gamma t_0$$
However, I am confused about how the speed of light stays the same in all reference frames through these equations. Imagine a rod moving relative to me at such a speed that $L' = 3 \cdot10^8$m and we know that the rod at rest has length $L_0 = 6\cdot10^8$m. Now if I see light go from one end of the rod to the other I record the time to be $1$ second. But In the reference frame of someone moving along at the same speed as the rod, they would see the light take $2$ seconds to go from one end to the other.
Therefore my time $t' = \frac{1}{2}t_0$ as something that took $1$ second to happen for me took $2$ seconds to happen for the other observer. But would this not make the equations $$L' = \frac{1}{2}L_0 \implies L' = \frac{1}{\gamma}L_0$$ $$t' = \frac{1}{2}t_0 \implies t' = \frac{1}{\gamma}t_0$$
I don't get what I did wrong to get the wrong equations.