More precisely, dogs wag their tails to get your attention, like a "hey." Could be happy ("heythereohmygodILOVEYOU"), could be wary ("Hey, uh...we're still cool, right?"), could be fearful/angry ("Hey asshole! You see me over here, right? Great! Now fuck off so we don't have to fight!"). The height of the tail, the ears and the hips carry most of the details.
Cats wag the end of their tails because they're agitated. If the tail is straight up high, that's usually happy; if it's low, that's usually fear or anger. If they're lashing the whole tail back and forth, that's "Imma pounce on this toy/playmate/prey animal and kill it." But they're cats, so they might be killing you happily or angrily or out of sheer psychotic interest. Cats is cats.