When they were first asked the question none of the three (A,B and C) could answer it.
Therefore none of the three could see two black hats.
Therefore either all three were wearing a white hat, or only two of them were wearing a white hat.
1. Having heard both B's and C's answer A could deduce that if only one of B and C was wearing a white hat then he too must be wearing a white hat.
2. If both B and C were wearing white hats then A could not have said which colour hat he was wearing. But he did say. Therefore only one of B and C was wearing a white hat. Therefore 1 above applied.