Men wearing hats walk on the street.
The men having hats on their head.
Men wearing hats is the same as men having hats and hats are worn on the head, so hats on their head.
The men can only be wearing hats on their heads while walking on the street.
Wearing hats means the same as having hats on their head.