The short answer is
The first batsman hit a single off a legal delivery, but the ball hit a fielders helmet which gives him 5 total 6. The second batsman hits a six.
Longer versions can have wides no balls etc.
The important thing was the bowler would have to get both men out in the same over if he wanted to bowl again that innings.
Rules change so this currently holds it might not in future
a woman got a cricket question right