These crushed stones are collectively known as “Track Ballast”. Track ballast is packed between the sleepers (concrete regular slabs), and on the sides of railway tracks.
The main purpose of the ballast (stones) is to hold sleepers in place, which helps to hold the rails in place.
Crushed stones also serve other purpose like draining of water beneath and around the tracks, stopping the plant growth to a certain extend and more importantly, holding the tracks firmly even in the case of super heavy trains.
If Railway tracks are not protected by the ballast (stones), this is what happens to the railroad tracks.
So now you know the reason why these crushed stones are there on Railway Tracks.