The man was suffering from a neurological condition called visual agnosia, so his brain was unable to process visual information properly.
His eyes were fine, but there was damage to part of brain called the occipital lobe (or possibly the temporal lobe- both parts of the brain are involved in how we make sense of our visual world).
The poor man could only focus on one part of the face at a time. So if he looked at a nose, he could not see the eyes or mouth.
The man (a patient studied by the famous neurologist, Oliver Sacks) was looking at the top of his wife’s head, but could not see her whole head.
This led him to believe he was looking at a hat stand, and he grabbed his wife’s head (which he thought was a hat) and tried to put it on.
The story has become very well known in medical literature and is featured in The Man Who Mistook his Wife for a Hat by Oliver Sacks, a collection of stories about neurological patients. The tragic story has also been made into an opera.
Luckily, when the man focused on his wife’s eyes and nose, he was finally able to recognise her.