am sorry I did not put down the question correctly. I meant why did Pinchas become Cohen only after he killed Zimri? but not before hand?
ב"ה Shalom I previously explained why Pinchas hadn't automatically become a Cohen and brought what Rashi says: Although, the Cehuna= priesthood had already been given to Aharon's descendants (See Shemot 28;41),it was given only to Aharon and his sons who had been anointed together with him and to their offspring which they would have after they had been anointed. But Pinchas who had been born before that had not been anointed had not yet attained the status of Cehuna until now (after the slaying of Zimri) . So too can we read in the Talmud Zevachim (101B) that Pinchas did not become a Cohen until he had slain Zimri. The answer to your question now is written explicitly in Torah. "He turned my anger from the Israelites, since he zealously took up my cause among them so I did not destroy them… Therefore tell him that I have given him my covenant of peace…this shall imply a covenant of eternal priesthood= Cehuna to him and his descendants after him." (Bamidbar 25: 11-13). Simply put, in reward to Pinchas for preventing Israel from sinning and thereby averting a plague upon them, Hashem rewarded him with the Cehuna. All the Best