This comes up on many threads over and over so here's a simple explanation all consolidated into a single thread.
A TVS goes in the system to prevent over-voltage stress from damaging electronics. This is different than a fuse or circuit breaker that protects from over-current stress. Unlike current at low frequency (60 Hz for most layouts) the transient voltage events that result from derailments, collisions, and general sparking are very broadband transient events, usually in the range of 1ns to 100ns.
That means they are a wave function, like a pulse of voltage bouncing up and down the wiring that has a fixed length, not like a continuous current flowing through it. At 1ns (so 1 GHz bandwidth) the wavelength in air is 11.8 inches and in RF we usually say 1/4 wave is where the wave effects start to matter.... so about 3 inches in air. However cables are not air and have a slower wave velocity depending on their dielectric constant (a property of the insulator) and their physical geometry (diameter, and how far apart the + and - are). All in all ... you can think of transient pulses as about a 1 inch wide event.
So if you put a TVS into a circuit and that TVS is more than an inch away from the thing you're trying to protect, chances are you're not actually protecting it because of the wave effects.
See the handy diagram below that explains what's going on. The bird is your electronics and the guy waving the rope is the train, making angry waves. If you pinch the cable in the wrong place (that's what a TVS does, clamp the cable voltage) the bird still gets bounced. The only way to avoid this is to do the pinching near the bird, in this case within the 1 inch.
and that's why the TVS needs to go in the locomotive right by the board, or in the TIU right by the drivers.
If you want a much more academic understanding.... Take a look at the telegrapher's equation.