The question to ask is "who owns the rail lines?". That matters for having a good rail system. It's basically the same problem for why the US doesn't have fiber internet available everywhere, too.
Good parallel. An article recently explained how Switzerland has the fastest fibre optical network: all companies share the same cabling. Dig once. No need to hook the property or do anything when switching provider.
For new rail at least, whoever wants to build them gets to own them, right?
I think what it comes down to is that if automobile companies had to build and maintain the roads, we certainly wouldn't have so many cars. But railway companies need to build the train lines, while competing with taxpayer funded automobile infrastructure. It's not impossible (see Japan) but also not easy.