Pets when placed utilise the current behaviour management process. If a player places a thrall/pet and puts that said pet/thrall on “Attack Nothing” then that NPC will obvisouly go into peace mode as-is.
However, should the player put that mode into other ones which in turn trigger aggro, then once a pet commits to a first attack of a player during non-raid times while guarding, then that pet is open to being attacked.
So the rules of engagement are simple - if players want their pets to be not killed during raid times, update their behaviour mode. If they want to use them as ward against offline rading etc, then attack mode is enabled. Players can’t kill a pet unless it attacks first.