Imagine that instead of a beam of light, a ball is rolled across the floor of the railway carriage from one side to the other. Upon hitting the opposite wall of the carriage, it bounces back to where it started.
In the frame of the train, the ball has travelled directly back and forth at right angles to the wall. In the frame of Bob at the trackside, the ball has taken a diagonal path toward the far wall and been reflected back on a diagonal path, with the angle of incidence equalling the angle of reflection. So far, so good.
Now, let us introduce a retroreflector at the far wall of the carriage which will ensure that the ball bounces back in the same direction in which it arrives (which we can make with two rigid surfaces joined at right angles, just as we could make a retroreflector for light with two mirrors).
On the train, the ball hits the retroreflector and bounces back as before. From the frame of reference of Bob, the ball is moving on a diagonal path, so following your argument the retroreflector should send the ball back on the diagonal path on which it arrived. It does no such thing, of course. The reason is that the retroreflector only reverses the path of the ball in the frame in which it is stationary.
From Bob's frame, both the ball and the retroreflector are moving. When the ball strikes the moving surfaces of the retroreflector, the angles of incidence and reflection are not equal, and the resulting effect is that, in Bob's frame, the retroreflector does not reverse the path of the ball.
The paper available at this link https://physics.weber.edu/galli/RelativisticReflection.pdf explains the underlying principles of the reflection of light from moving mirrors. It contains the case of a moving mirror angled at 45 degrees to its direction of motion, from which it is straightforward to establish that a moving retroreflector made of two mirrors each angled at 45 degrees to the direction of motion will not reverse the path of the incident light in Bob's frame, but will return the light to the source.