>>1496161It depends on many factors, like fuel price, cost of electricity, geography...
In Europe railways are largely electrified because electricity is often quite cheap while fuel isn't, lines have higher density and more stops, higher speed and acceleration is valued more, lines run through more urban areas with available electric grid and less exposed to damage (unlike rail tracks running through a lot of nothingness), etc.
In the US some lines would likely be more economical if they were electrified, around the coasts and Chicago, where there's more passenger and commuter trains, and generally more train density and more urban density. However on one hand this requires a huge investment which would take many decades to offset, and huge chunks would have to electrified almost at once for it to make sense. It's quite understandable why this isn't done.
Although I don't get why the government doesn't pay for electrification of certain lines with relatively high passenger and commuter traffic. Kinda like Caltrain is doing, just with privately owned tracks. I guess this would mean a shitload of bureaucracy that noone wants to deal with.