Kevin's moral code prevented taking deadly action. However, a being of such power as him surely could have taken actions that would have ended the attack without killing or injuring any Husnock. As an "immortal being of disguises and false surroundings" he probably could have made it appear to the Husnock that the entire planet was no longer there, or other appropriate illusion to cause them to stop the attack and leave.
This was explicitly addressed in the episode; The relevant conversation:
CRUSHER: You had the power to stop them but you didn't?
KEVIN: I refused to for the same reason I refused to stop the Enterprise. I will not kill.
PICARD: So you let the colonists fight a hopeless battle.
KEVIN: I tried to fool the Husnock as I tried to fool you. It only made them angrier. More cruel.
(Emphasis by me)
As you can see, he tried to use his abilities to prevent the genocide, but the Husnock didn't buy his tricks (just as Picard didn't). So it appears he's not very good at deception on such a large scale.