The Matnas Kehuna actually writes that the point of the medrash rabba so as not become impure, actually means so as not to become dirty.

>שלא יטמא. כלומר שלא ילכלך ויטנף אותו.

Pirush Maharzo quotes this Matnas Kehuna but offers a different explanation. He suggests that considering how Kozbi was speared, the blood uber discussion was actually blood from her makor, dam nida. Which is only impure on a rabbinic level by nonjews, but nonetheless, this miracle spared Pinchas from even that.

>שהרי דם זה בא מן המקור שדקר אותה שם והוא טמא ומטמא עכ׳פ מדרבנן בעובדי כוכבים