To understand this, we need to look at two things.
The first is typology. For example, Christ is the new Adam and the new Moses in traditional Catholic teaching. This refers to his role as Saviour of mankind and as law-giver, but it does not mean that he is Adam or Moses. If someone had asked Christ to his face, “Are you Adam?”, he would’ve answered “I am not.”
Similarly, Elijah is a type - or a precursor - of John the Baptist. Just as Elijah was the first and perhaps the greatest of the Prophets, John the Baptist was the last of the Prophets.
Second, St. John the Baptist is the fulfillment of Malachi’s prophecy: “Lo, I will send you the prophet Elijah before the great and terrible day of the LORD comes.” Like most of the Prophets, Malachi uses figurative language to speak of Christ’s precursor. That this prophecy refers to John the Baptist is made clear in Luke 1:17, which echoes this prophecy.
Summing up, he is the “symbolic” Elijah of Malachi’s prophecy, but not a “physical” Elijah. This is why, when asked “Are you Elijah” (that is, the Prophet Elijah of 1 Kings), John replied “No”.