He looks over and sees Obi-Wan at the bar. He walks forward and sees a second Obi-Wan. He puts two and two together.
Keep in mind that the whole first part of this scene sets up that she’s a shapeshifter and Anakin needs to be careful.
I don’t know how to make it any less confusing. Also, the shock of Anakin suddenly slicing Obi-Wan and the revelation that it wasn’t him is supposed to be fun foreshadowing.