Many lines used to have double or quadruple or even electrification but are now single unpowered tracks, because the additional improvements counted towards property tax assessments. It's just not a level playing field.
ps: obligatory history article https://www.lowtechmagazine.com/2008/02/a-world-without.html
I guess no one is building one lane freeways, but I was still surprised by how much more expensive rail is.
(This is just the result of a basic Google search. It also says maintenance costs are "much less" for the railway.)
There are probably economy-of-scale issue too (we build a lot more roads), and different expectations of road vs. rail safety (a rail accident with a few injuries has national media coverage for days, upgrades costing millions may be rolled out to prevent a repeat; every day several people die on roads, the infrastructure is rarely improved).
sort of like a shared packet network compared to a centrally managed circuit switched network