In the first passage you quoted, John was being questioned by the Jewish religious leaders about whether he was Elijah. Their question was whether he was literally Elijah returned from heaven. In answer to that question, John said “No” because he was not a literal reincarnation of Elijah.
In the second passage, Jesus is answering a question of the disciples about the fulfillment of prophecy. The disciples want to know why the scribes say that Elijah must return before the messianic age. Jesus answers that he has returned and the disciples understand him to be referring to John the Baptist. In this case, Jesus is speaking metaphorically. John the Baptist is not literally Elijah, but he has acted as Elijah in heralding the arrival of the Messiah.
Christians do not believe in a literal reincarnation, but they do believe that it is possible that a person can be a living reminder or symbol of another person. A secular example of this phenomenon might be how politicians are sometimes compared to predecessors (e.g., “He governs in the tradition of Thomas Jefferson”; or “He’s a new John Kennedy”). For a religious example of the phenomenon, please see second article linked below.
DISCLAIMER: Catholic Answers has turned over the archive to Catholic-Questions.org and no longer owns, manages, or moderates the forums. For additional apologetics resources please visit www.catholic.com.