The din of Kanaaim Pogim Bo is that the Kanai must be completely li-shem shomayim. One can't kill unless his motivations are completely pure [that is the assumption of many, many sefarim. See for example אגרות משה אבה"ע סי' ל"ח. However - I didn't find this explicitly in Chazal].
So why don't we say the same thing regarding the witnesses who carry out מיתת בית דין - as the pasuk says יד העדים תהיה בו בראשונה להמיתו. There we don't require pure intentions, just that the person be כשר לעדות!? Why not? In both cases capital punishment is being carried out and should require pure motivations because mitzvos such as capital punishment must be done with only the purest of intentions and no personal interests or vendettas?!