The machine gun, a weapon that reshaped modern warfare, emerged after centuries of experimentation with rapid-fire arms.