So, the first man didnt know what hat color he had on, which means he did not see 2 black hats otherwise he would have a white for sure.

The second man knew that the first man did not see 2 black hats in front of him, so he knew that the first man must have seen either 2 white hats or a white and a black hat, the man in the middle knew that if he see a black hat in front of him he than he MUST have a white hat on, but since he didnt know what hat he had on, it means he did not see a black hat in front of him, analyzing this, the last man knew he had a white hat on.