But they have diesel generators to run them. They use the electric motors because of the low-end torque, IIRC. For a locomotive to be EV, the battery pack would have to be multiple railroad cars worth. Who knows how many..
Or maybe just use a positive and negative rail instead.
I can’t see any possible way that could end badly.
(except for Tesla owners trying to charge their cars on the tracks maybe)