A mix of politics, bureaucracy, and cost. For example, there was a fatal derailment back in 2017 in the US, and an automated safety system that may have prevented it was delayed.
From the wikipedia article on Positive Train Control (PTC):
>In December 2010, the U.S. Government Accountability Office (GAO) reported that Amtrak and the major Class I railroads have taken steps to install PTC systems under the law, but commuter rail operators were not on track for the 2015 deadline.[14] As of June 2015, only seven commuter systems (29 percent of those represented by APTA) were expecting to make the deadline. Several factors have delayed implementation, including the need to obtain funding (which was not provided by Congress); the time it has taken to design, test, make interoperable, and manufacture the technology; and the need to obtain radio spectrum along the entire rail network, which involves FCC permission and in some cases negotiating with an existing owner for purchase or lease.[15]
So needless to say... the technology likely exists today, but implementing anything significant to existing infrastructure in the US is a monumental feat.
The above example is just a safety system, but once you start removing employees you also start running up against labor unions... which is yet another layer holding things back.
Well, BART had one crash because the automated control system mis-read a command and accelerated when it should have been braking. Debuggable? Perhaps. But after that, it's a tough sell to say that there shouldn't be a human in the cab to say "Wait a minute, that's not right."
American Freight automation will be a crazy beast. Closed lines can be fully automated, and we are seeing a lot of PTC (positive train control) such as automatically enforcing speed limits and collision detection. The driver is supposed to know when they are approaching a red signal -- nowadays the engine notices too.
However, the nationwide freight network is interconnected by many different companies, in various states of repair, with various states of mechanization. I live near a bunch of grain processors and when they are taking deliveries it is a lot of manual switching and back and forth to get each plant's cars to the right lines.
Could it be automated? Yes, the technology is available, you 'just' have to implement it. Will it be? Probably not anytime soon.
Unfortunately there has been a prolonged campaign(ennui?) against rail in the US. I imagine lack of funding for innovation in legacy rail systems is to blame here.
Rail cannot get adequate funding for even basic maintenance and upkeep and upgrades, let alone modernization, because of widespread corruption among government officials and public sector workers. I'm sure public perception plays some role but it is not the root cause for our current situation.
The legal liability issue. If you have a human driver, you can blame them add an individual for any incidents. If you have software in control, the company that runs the train or developed the software is liable.