It can be: In some jurisdictions such as the United States, railway companies may combine these roles.
In Europe, the EU requires its members to separate the national railway infrastructure managers from railway undertakings which are public and private companies providing services by operating rolling stock.
This ensures conditions enabling the latter companies to compete fairly among each other, with multiple companies bidding for the privilege to operate the line for a limited time period under public service obligation aided by railway subsidies or under franchising.
Some countries have in turn a national railway company that owns all track and operates all trains in the country, for instance the Russian Railways[2] (the world's largest rail company by network size).
Other countries have many different, sometimes competing, railway companies that operate each their own lines, particularly in the United States and Canada.