Some snakes (young king or milk snakes- typical example) also defecate in self-defense; handling scares them & by "tasting bad" they reduce the chance of a predator eating them & just letting them go.
So keep in mind that you just might be scaring the "pee & poo" out of your snake, that's why it's so frequent. Take the hint...slow down, handle less while your snake learns to trust you as "safe", not a predator.