Railways are often considered a typical example of a natural monopoly. The very high costs of laying track and building a network, as well as the costs of buying or leasing the trains, would prohibit, or deter, the entry of a competitor.
To society, the costs associated with building and running a rival network would be wasteful.
Car rental companies operate in a competitive market, as do gas stations. Competitive markets are pretty good at driving prices down.
Trains tend not to.
https://www.economicsonline.co.uk/business_economics/natural_monopolies.html/