Don't be lost. Remember that native speakers of any language sometimes disagree about their language. This usually means that there is no widely accepted rule or that the 'rule' is flexible, maybe depending on the circumstances.
In the first sentence, I would say "hats"; in the second, I would say "head". Maybe the following attempt at an explanation will help, but it is difficult to explain this well in a few written words.
The first sentence states a general impersonal rule that applies to all men wearing (a hat)(hats). "Men will remove their hat...." sounds very odd, like all the men together have only one hat.
In the second sentence, although you are addressing many children, you are personally asking each one to touch his or her head right now. If you say "Children, touch your heads.", some of them will laugh and want to tell you they (each) have only one head.
So, language often has to be adapted to the situation, but this is not an easy thing to learn or, more correctly, develop a feel for.
Say, Should "hat" be replaced by "hats" here?
Student or Learner