Photographs and videos on social media of an enraged mob that seized the man from a jail, dragged him through the streets and beat him to death helped lead to the arrests, the authorities said.