Not sure about other countries, but Germany's long distance trains are run for-profit. Only commuter trains are subsidized. Tracks are paid for by taxes - but so are streets.
In most European countries, even if the financing is organized differently than in Germany, the long-distance trains bring in the most money and would be profitable if run entirely commercially.