Either 1) Dajjal was definitely supposed to appear only after the Prophet or 2) it was possible for him to appear in the Prophet's lifetime.
If the first, maybe the Prophet was not informed of that at the time he made this dua. If he was also informed of it when he made the dua, maybe he did it to set an example for his people.
If the second, Dajjal could have appeared in the Prophet's time if Allah wanted, but Allah decided to delay him. The Prophet was reported saying: "If Dajjal appears while I am with you, I will defend you against him. But if he appears after I die, then everyone of you is his own defender" (Sahih Muslim) indicating that at least at the time the statement was said Dajjal and Jesus could possibly have come in his time.
Furthermore, Ibn Sayyad being suspected as the Dajjal by the Prophet and companions indicates they weren't sure (at least at the time) that Dajjal would only appear after the Prophet.
Maybe a combination of the two occurred: the Prophet was originally not told Dajjal would be after him so he made the dua then he was told and he continued to make it to set an example.
And Allah knows best.