$$S'$$ IS the lab frame, the clocks don't line up in $$S'$$, you don't know your own setup?
My mistake, I am sorry. I've been using the natural convention of $$S$$ for the ground frame and $$S'$$ for the car frame. I note that
you introduced the opposite convention (it's not part of my setup).
So let's go back to where this misunderstanding originated and clarify.
Let $$S$$ be the frame of the moving 1000km (!!!) rail car with the clocks at both ends and $$S'$$ the frame of the rails. The $$S'$$ clocks are situated $$L=1000km$$ apart. We will label the clocks A and B:
There are four clocks. Let us label the ground clocks $$Ag$$ and $$Bg$$, and the rail clocks $$Ar$$ and $$Br$$.
In the below calculations, you seem to use $$A$$ to refer to the event of $$Ar$$ and $$Ag$$ aligning, and $$B$$ to refer to the event of $$Br$$ and $$Bg$$ aligning.
$$t'_A=\gamma(t_A+vx_A/c^2)$$
$$t'_B=\gamma(t_B+vx_B/c^2)$$
I notice you've used the convention that $$v$$ is the velocity of $$S$$ relative to $$S'$$, rather than the other way round. Any particular reason?
The $$S$$ clocks are synchronized, so:
$$t_A=t_B=t_0$$
Your labels are not clear.
I'm guessing that:
$$t_A = $$ the time in $$S$$ at which $$Ag$$ and $$Ar$$ align.
$$t_B = $$ the time in $$S$$ at which $$Bg$$ and $$Br$$ align.
So, you've set the clocks to align simultaneously in the car frame.
This is the opposite to what was specified in the setup, but let's run with it anyway.
And these appears to be is the positions at which the clocks align:
$$x_A = $$ the position in $$S$$ at which $$Ag$$ and $$Ar$$ align.
$$x_B = $$ the position in $$S$$ at which $$Bg$$ and $$Br$$ align.
so:
$$t'_A=\gamma t_0$$
$$t'_B=\gamma t_0+\gamma vL/c^2$$
Therefore:
$$t'_B-t'_A=\gamma vL/c^2$$
No surprise here.
So the clocks do not line up simultaneously in the $$S'$$, as shown by the times $$t'_A$$ and $$t'_B$$ record on the $$S'$$ clocks $$Ag$$ and $$Bg$$. This is enough to measure relativity of simultaneity - the events A and B are simultaneous in $$S$$, and not simultaneous in $$S'$$.
But:
$$x'_A=\gamma(x_A+vt_A)=\gamma vt_0$$
$$x'_B=\gamma(x_B+vt_B)=\gamma vt_0+\gamma L$$
So, your scenario has a flaw, the clocks on the rail car do not line up with the clocks on the ground, the clock at B in the railcar is measured by the platform as being way past to the right of the corresponding ground clock. No wonder the ground clock has accumulated the extra time, the railcar clock has passed it by quite a bit. The larger the relative speed, the larger the missalignment, both spatial and temporal
In $$S$$, the clocks align simultaneously.
In $$S'$$, the clocks do not align simultaneously, with a measured time difference.
Obviously, this means that in $$S'$$ the distance between $$Ar$$ and $$Br$$ is not the same as the distance between $$Ag$$ and $$Bg$$. If it was the same, then the would align simultaneously, which would mean that the events A and B were simultaneous in both $$S$$ and $$S'$$.
The whole point of the experiment is that the clocks are aligned in $$S$$ at a particular instant, and always misaligned in $$S'$$