A dog will wag its tail when it sees its owner because the dog is happy to see its owner.
It means the dog is moving its tail from side to side.
In Australia, the word wag has a colloquial meaning of skipping or missing out on something.
We say - The students who wag school will be punished with a detention.