If someone catches an overhead railway power line while standing on top of a train, why wouldn't others in the train be electrocuted also?
You only get an electric shock if the current flows through you.  Anyone inside the train won't be affected simply because they are inside a metal box.  The current flows round the outside and doesn't bother them.

Anyone hanging on the outside of the train, or leaning out of a door, is unlikely to be affected either because the metal body of the train is a much better conductor than a person.  Most of the current would flow through the train body, not the person.

Somebody on the platform may get a shock.  But the metal train wheels on the metal rails make a far better ground connection than a person on a platform.  So the shock would be a lot less than might be expected.