Seeing a dog wagging their tail and immediately assuming they are friendly is the wrong assumption. Tail wagging is a way for dogs to single their emotions, and while frequently these are happy emotions, this is not always the case. While it does represents happiness in a dog, Door County Pulse says the technical meaning is " a dog is mentally aroused and engaged with what is going on in his environment."
As this is a sign of emotions, not always positive, people still must be cautious around dogs wagging their tails. Dogs will still defend when their tail is wagging, and can still bite someone.
https://doorcountypulse.com/pet-talk-a/