Dogs can't use their words to express their displeasure so they resort to visual and auditory clues like snarling, barking and growling to warn people and other animals that they're not okay.
And yet people don't seem to be picking up on these signals, so they're constantly getting bitten by dogs who just want to be left alone.
That "smile" on a dog's face when a stranger approaches them and tries to pet them without a proper introduction?
It may mean the dog wants to bite the stranger's hand for being such a pushy jerk, but most socialized dogs who have been raised around people resist the urge to snap.
Their wagging tail can also be misconstrued as a positive reaction to a person:
The tail can send a bunch of different emotional signals, depending on the kind of wag. For instance, look at the height of the tail -- if Spot is holding his tail up high, he's warning you.
If the tail is a little lower, he's more calm. If he's keeping it down near the "between the legs" position, he's scared.
Then you also have to consider the direction of the wag. A dog wagging its tail more to the right has noticed something it is cool with and would like to approach. However, if the wagging is switched to the left, it indicates anxiety. All of these nuances of wagging can convey a wide spectrum of different emotions to other dogs from a safe distance.
See 5 Adorable Behaviors That Mean Your Dog Hates You here (NSFW language)