This scent-marking behavior is done to spread pheromones around that a male snake can detect and follow. Likewise, when males tail-wag, they are advertising to other males that there is competition in the area, and to females that there's a guy around looking for them.
A female snake ready to breed tail-wags to spread her scent so a male can find her more easily. These pheromones also trigger his instincts so he will succeed in mating with them.