The rails are firmly fixed, longitudinally as well as laterally, with pretensioning in order to minimise stress as they heat up. This is true with ties as much as with a concrete bed.
https://interfacejournal.com/archives/644
"There are a number of ways to increase the resistance of rail to buckling. The first and most common is the use of rail anchors to limit the longitudinal expansion of the rail. Anchors come in a variety of designs, but they all apply several thousand pounds of clamping force on the base of the rail. When applied properly against each side of the crossties, the anchors prevent expansion of the rail in the longitudinal direction."
The general approach is described here: https://en.wikipedia.org/wiki/Rail_stressing