I just wanted to add my observation--the guards will attack and kill anything that is CONSISTENTLY hostile towards people. If it is something/someone you have provoked that would not otherwise be hostile towards you, the guard will ignore it. (This does not, of course, address the bug of having everyone attack you unprovoked, then the guards "defending" them, etc.)
Early on in the game, when I was still weak, I would run back to the nearest village and let the guard kill the Kwanza whatjamajizits (the worm-looking things with one eye that you run into early on). After I saw one of the non-hostile little purple critters appear to give birth to one of the hostile worms, I started killing non-hostile little purple critters on sight, hoping to nip the problem in the bud. (This may have been a bug or something weird, since it's now my understanding the nasty worm things come from eggs laid by large critters in caves??) When I ran back to a village with a little purple critter I had provoked on my heels, it was a different story--the guard completely ignored its presence.