How does hot weather affect trains?
A sharp change of temperature from cool to hot or vice versa can lead to rails expanding or contracting too much and thus affecting gauge, usually only slightly. Modern continuously welded rail is supposed to be securely tied to sleepers to prevent excessive expansion or contraction.
Ideally, rails are laid at a median temperature between what is expected to be the highest and lowest ambient temperature in that area. This is obviously not an exact science and extremes of temperature can cause problems and the ties may fail to cope with the expansion/contraction. Despite this, gauge is usually maintained within acceptable limits, (sometimes with expansion joints in known problem areas) but speed restrictions maybe put in place as a precaution.
Just occasionally the expansion/contraction is so severe as to break the gauge between rails, but this is very rare and there have been few, if any, incidences in modern times of a derailment of a passenger service from this cause.