I find that the best solution to relativity conundrums is to apply the
Lorentz transformations.
Let the light enter the train at the origin in both reference frames. The
train moves in the +x direction according to the track frame. The light
moves across the track in the +y direction in the track frame. The width
of the train is w, same in both frames.
In track frame, time of light leaving train is simply w/c. Location of
that event is x=0, y=w, t=w/c.
Now plug those numbers into the Lorentz transformations to find the
spacetime locations for the leaving-train event in the train frame.
x' = gamma * (0 - v*t) = - gamma * v * w / c
y' = w
t' = gamma *(t - (v/c^2)x) = gamma * w/c
Now, find the distance travelled in the train frame:
d'^2 = x'^2 + y'^2 = (gamma * v * w / c)^2 + w^2 = w^2 * ( gamma^2 * (v/c)
^2 + 1)
or, after substituting for gamma and doing some algebra,
d'^2 = (gamma * w)^2.
Then, d'/t' = c, as expected. Contrary to my previous post, this
derivation does not involve the clock-synchronization term of the
transformations. If you worked the other way, starting in the train frame
and transforming to the track frame, that term would come into play.