It seems to me that the problems that trains and rail infrastructure is facing are: bureaucracy, politics and an increasing inability to execute on infrastructure projects on time/budget by governments.
To the extent cost is a a factor, it's unnecessarily high due to these aforementioned issues[1]. So I don't think money invested into self-driving cars hurts trains and rail infrastructure.
[1]: https://www.vox.com/policy-and-politics/2017/1/1/14112776/ne...