Yep they do; it's a defense mechanism. They basically blast the "predator" with a super stinky, horribly acrid smell/taste to make them let the snake go... And I say taste because often times the snake is in a predators mouth when it's being attacked. It's kind of like what skunks do with their whole spraying thing, except snakes don't spray and I don't think snake musk can blind like skunk spray does. It's not a fart or anything like that, though I'm not exactly sure where the smell/substance is secreted from.
Sometimes snakes will musk a tiny bit when they're startled or disturbed, not like a full-blast musk. Your substrate sounds fine so I think that's probably what happened. Be happy you haven't experienced the full stench of a musking snake lol![]()