There are there in case of derailment to catch the wheels and stop or reduce the movement of the train sideways.
If you look at you images and the wheel closer to you would jump the track the wheel on the other side would hit the track in the middle and hopefully stop the sideways motion towards you.
Those look to be guide rails. They are there so if the train derails the wheels will hit the inner rail and stop the train from deviating too much from the path of the rails. This is particularly helpful around stations where a train coming through to one side or the other of the tracks would squish a lot of people.
Latest Answers