https://www.youtube.com/watch?v=_LoXgN1QWZM
https://www.youtube.com/watch?v=dqq0543JWzI (wiggle wiggle)
Second, in most modern rail installations the track is pre-tensioned to deal with thermal expansion. The track is stretched with a hydraulic tool and welded while under tension, so thermal expansion just means reduced tension. This is why trains on modern rail lines don't make the familiar click-clack sound.
(How much tension is applied depends on the country and weather - you can choose between tolerating high temperatures and tolerating low temperatures. This is why in the UK, there are sometimes train stoppages in very hot weather)
What does the click-clack sound have to do with thermal expansion? Is it because the track is expanding as the train moves over it, if so what’s causing that sound signature?
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
Usually they are joined to a rail with a slant cut or a tongue section at ends, and let ride into the opposing cuts/tongues, IIUC.
The rail can only expand if it can move. If the rail is clamped down tightly to the sleepers, and the sleepers are tightly packed in the ballast, then it just doesn't expand. The only thing that happens is that stress increases / decreases as temperature changes.
The pre-tensioning is only to ensure that the average tension in rail in the course of an average year is in a certain range.