When you kill an entity that you are viewing in spectator mode it also kills you
If you are view a pig then if you go
/kill @e then it also kills you as well as the pig.
This might be a problem if in a server if you are suspecting in an entity or a player then someone kills the entity or player it kills you, this may also be counted on a scoreboard as an other player kill.
It's also very annoying.
@e targets all entities in the world, including the player.
You may want to use @e[type=Pig]