Either Pinchas actually lived 12 generations, as is implied in the Zmiros איש שנים עשר דורות ראו עיניו, or it means, as often it does when Chazal say such things, that Eliyahu was the Gilgul, or Shoresh Haneshamah, of Pinchas (see Megaleh Amukos Vayigash, Radvaz Teshuvos 6:2:2203, and others) brings both options.
As to the Rambam, it's not such a terrible problem, since in context the Rambam is talking about giving over the chain of the Mesorah and it is very likely that Pinchas/Eliyahu was the Mesorah-giver twice: Once to the generaiton where he was Pinchas and the other time to the generation where he was Pinchas. Those were two different generations in which he served as the once of the main givers of the Mesorah and so he is listed twice.
But more likely, it's simply because even when we say Pinchas and Eliyahu were the same person, he still had two different Neshomos, which is why he had 2 different names (Leshem 1:5:7). So you can call them the same person or you can say they were not the same - depending on what exactly you mean.