Obviously there have been a lot of books written on the subject. And yes, the railroads fell afoul of a changing country. The building of the interstate highway system made long haul trucking practical and also allowed for longer distance car travel, while air travel started taking over long distance travel. The railroads also faced ICC regulations that gave trucks and airlines an unfair advantage with pricing, even though trucks and planes were regulated, plus railroads thanks to regulation had a really hard time being able to drop routes/abandon unprofitable lines because of political pushback from the areas to be dropped.
I did some reading in grad school on the railroads and my take on it was that railroad management basically failed to anticipate the future, and from what I recall a lot of that was the people in charge were 'professional managers', of the school of thought "a good manager can manage anything." , and I personally think that doomed them. The problem was the railroads after the uncertainty of the 1930's depression, were obviously flying high during WWII and the immediate postwar era, and those 'good times' made them blind to the future (I also suspect some of them looked and said "the times are good, let's take everything we can out of it" ie greed as well). The railroads in the immediate post war period could and should have been pushing for regulation overhaul, and also evaluating what the future would bring. There were managers there doing that, you can see it with things like the somewhat silly "Jet Locomotive" the NYC tried, and there were attempts to make rail travel competitive in other ways, modernizing train stations, trying to offer service the airlines couldn't. On the freight side there were people pushing to re-evaluate routes and I seem to recall with the NYC someone tried to promote using early computer systems to handle freight routing (talking mid 50's) but obviously got nowhere with it.
In the end like most things it isn't as much heroes and villains (though I am sure there are both of those), it is more like typical human nature, being able to rationalize away the obvious and pretend like everything is fine, until it is too late. I think the management of both railroads, the ones making the decisions, were resting on their laurels rather than looking at change, and that is always fatal. It must have driven the railroad guys nuts, they likely saw what was happening on the ground and it was lost going up the food chain. I also will add that this didn't just affect the railroads, that is the story of much of corporate America, the railroads were 20 years ahead of the auto industry meltdown, for example, same kind of entrenched thinking, etc.