A batsman can get out because he handled the ball. This means that he had touched the ball with his hands without the permission of the fielding team. This can happen when he attempts the secure the wicket, after he hit the ball with the bat; for example, when the ball is rolling back at the wicket. However, the batsman is allowed to use his feet, bat or pads.
Notice, the batsman can be hit at the hand during the delivery or because of any other actions. Also it the batsman picks up the ball to give it back to the fielding team. For those actions, the batsman can not get out.