C-3PO recognizes Anakin when he returns to Tatooine in *Star Wars: Episode II – Attack of the Clones*.
Anakin and Padmé travel to Tatooine after Anakin senses that his mother, Shmi Skywalker, is in danger. At the Lars homestead, C-3PO—whom Anakin built years earlier from salvaged parts—greets Anakin and immediately recognizes him. The reunion connects Anakin’s childhood on Tatooine with his later life as a Jedi.
A common mix-up is R2-D2, because R2-D2 is Anakin’s closest droid companion during the Clone Wars and also appears with him throughout the prequel trilogy. However, R2-D2 is not the droid who verbally recognizes Anakin at the Lars homestead. C-3PO had remained on Tatooine after Anakin left to become a Jedi, eventually becoming part of the Lars family’s household.
The scene also highlights C-3PO’s unusual history: Anakin constructed him to help his mother, Shmi, before either droid became associated with Luke Skywalker and the Rebellion.