https://www.eea.europa.eu/publications/technical_report_2007...
In other words, it makes sense to subsidize rail, it doesn't make sense to subsidize modes with higher externalities.
There are many factors affecting pricing, for example occupancy rate. Load factor of aircrafts are in the 80 percentage - [0], whereas it's often under 60% for long distance Deutsche Bahn's trains in Germany - [1]
Another possibility is that train operators are often state owned and therefore face less competition and are less efficient than airliners, who are used to operate in a cutthroat environment.
Note that I don't claim either of the above cause train's pricing disadvantage, merely they are factors to consider. OTOTH attributing pricing advantage to subsidy is a lazy take of a complex issue.
[0] - https://www.statista.com/statistics/658830/passenger-load-fa...
[1] - https://www.statista.com/statistics/654973/long-distance-tra...
Nothing wrong with optimizing for cost - if all externalities are properly priced. Otherwise its just egotistical behavior (don't mess with my habits) that passes as "common sense".
[1] https://www.transportenvironment.org/challenges/planes/subsi...