Rashi (quoting Sanhedrin 82b) states that Pinchas' mother was the daughter of Puti (Yisro). We know that a kohen may not marry a convert (Shulchan Aruch Even Haezer 6,8), and if a kohen does marry a convert his children are not considered kohanim. Because of this, how could Pinchas have been a kohen?
Gemara in Yevamos 60b asks almost exactly the same question about Pinchas marrying one of the midyanite girls after capture from war:
תניא ר' שמעון בן יוחי אומר גיורת פחותה מבת שלש שנים ויום אחד כשירה לכהונה שנאמר (במדבר לא, יח) וכל הטף בנשים אשר לא ידעו משכב זכר החיו לכם והרי פנחס עמהם Rabbi Shimon bar Yochanan said a Giyores that converted to Judaism under the age of 3 is permitted to marry a kohen as it says the girls you shall keep for yourselves and Pinchos was among them.
According to this the daughter of Yisro could have converted under the age of 3.
However as we pasken like Rabbi Eliezer Ben Yaakov in that gemora who says that 1 parent must be a Yisroel and 1 can be a convert, one of Elazars wifes parents was from the tribe of Yosef and the other was from Yisro so everything is fine.
Since Pinchas was born before Yetzias Mitzraim, Elazar was not a kohen at the time of his marriage. Additionally, Aharon and his children were explicitly appointed to the kehuna by Hashem, as was Pinchas. Thus the rules you reference would have applied only to their children, not to them.
Rashi Bamidbar 25:13
והיתה לו. בריתי זאת: ברית כהנת עולם. שאף על פי שכבר נתנה כהנה לזרעו של אהרן, לא נתנה אלא לאהרן ולבניו, שנמשחו עמו ולתולדותיהם שיולידו אחר המשחתן, אבל פנחס שנלד קודם לכן ולא נמשח, לא בא לכלל כהנה עד כאן. וכן שנינו בזבחים (קא, ב) לא נתכהן פנחס עד שהרגו לזמרי: Based on Gemara zvachim 101b
Since Pinehas was already born (the Gemara's statement) when Elazar received the kehuna, we can logically infer that Elazar was already married before this event.