4 Hats Riddle Answer

There are four prisoners. All four prisoners will be freed if at least one of them correctly guesses the color of the hat on his head. They can’t speak to each other, and they can’t touch each other.
Number 1 sees number 2 and 3’s hats.
Number 2 sees number 3’s hat.
Number 3 sees only the wall.
Number 4 sees only the wall.
There are no mirrors.
They all know that there are 2 black hats and 2 white hats and that there are four people.
They know their placement in this room is as follows:
Can the four prisoners be freed? If so, how?

4 can’t see the other three due to the wall so he can’t guess.
3 also can’t see due to the wall.
I eliminate 4 and 3.
For 2, he knows 3 is wearing a white hat. But how could he know he is wearing black?
For 1, if 2 hat is white then 1 hat is black. But if 1’s is black and 2’s is white then, he would be able to know. If the two in front have white hats then, he will answer first and say ‘Mine is black’.
But properly, 2 is aware of 1’s hesitation, ‘Oh 1 is also white’.
Then, 2 will answer ‘Mine is black’. So the answer is 2.