Rail construction is more expensive because the loads are way higher - axle loads of 22-25 metric tons are common (https://www.forschungsinformationssystem.de/servlet/is/32505...), trucks are half to a third of that (usually 8t/axle, legal limit in Germany are 10t). The forces on the rails are also greater especially if higher speeds are involved - trucks here have a limit of 80 km/h and buses 100 km/h, whereas trains reach triple that.