The crushed stones alongside railway tracks are called ballast.
They provide a smooth and consistent surface for the tracks, and this means a smooth run for the train.
By using crushed stones, rather than say a solid block of concrete, movement due to trains and heat can be absorbed by the stones.
It is also easier for water to drain away from the track.
Crushed stones, called ballast, support the train tracks and allow water to drain.
For rail lines that use certain types of electrical systems in the rails, ballast also provides insulation between the rails.