(Numbers 25:13:) "AND IT SHALL BELONG TO HIM AND TO HIS SEED AFTER HIM [etc.] AND HE MADE ATONEMENT FOR THE CHILDREN OF ISRAEL." Now did he offer a sacrifice, that atonement is spoken of concerning him? Rather, it is to teach you that anyone who sheds the blood of the wicked is as though he had offered a sacrifice.
Why Pinchas Slaying the Wicked Counts as a Sacrifice
Midrash Tanchuma Buber, Pinchas 3:3
והיתה לו ולזרעו אחריו [וגו'] ויכפר על בני ישראל (במדבר שם יג). וכי קרבן הקריב שנאמר בו כפרה, אלא ללמדך שכל השופך דמם של רשעים כאילו הקריב קרבן.