Track ballast are the rough stones found under and alongside railway tracks that form the bed on which sleepers are laid, helping to maintain railway tracks and ensure the safety of the railway vehicles travelling along them. They are extremely rough and sharp-edged, ensuring that the stones do not move when a train passes over, creating a stable base for the railway sleepers and track to be laid. Ballast also helps to protect against potential issues that could cause defects in the track such as expansion and vibration, growth of vegetation and roots from trees and flooding. Railway sleepers are laid perpendicular to the direction of the track at equal spacing apart with a main function of providing a stable, even platform for the railway tracks.
https://www.alpharail.co.nz/why-do-railway-tracks-have-crushed-stones-alongside-them/