Logistics is complex; you'll also need to factor many things into the optimization: * both fixed and marginal costs of each mode (e.g. maintaining track, monitoring safety, wear and tear on vehicles, varying fuel costs) * constraints (due to technology, personnel, regulations, etc) * fluctuations in demand and shipping objectives * lots more
If you want to focus on only one slice of the problem... Sure, for the exact same route (meaning that a particular track has already been built), one would expect that trains are more efficient. The data shows that; e.g. https://en.wikipedia.org/wiki/Energy_efficiency_in_transport...
I think any definition of competition must be relative to the sphere of economic activity. So, when it comes to transportation in general, rail and trucks do compete -- by this I mean they offer services with varying prices and characteristics.
Just because rail and trucking have different sweet spots at a particular point in time does not mean that they don't compete. Both (a) think about how and why customers choose them over the other, (b) seek opportunities (for investment or growth) that lead to a competitive edge, and (c) therefore, influence each other.