These are small explosive charges used to warn trains about track damage/restrictions ahead. If the gangmen observe any problems up ahead, they place these charges on the track. When the train passes over the charge, it explodes and the loco pilot understands that it's a warning.