The animation appears to be as seen in a frame that is accelerating with
carriage A, and I think you intend that both start at the same time, in the
initial rest frame. In that case the top animation with the carriages pulling
apart is mostly correct.
I say mostly correct because the animation does not take into account how
the observers in carriage A will see only a delayed image of B, and thus
when starting up will initially see B stationary for a moment before the
light from B gets to A. In fact A will always see a delayed image of B,
yet the string will stretch and break. Likewise, initially the string will
not be pulled by B, as seen at A, until the acceleration of B can
propagate down the string at the speed of sound.
Also you do not show the Lorentz contraction of the railroad ties as the
carriages speed increases. That is happening also.
Rich L.