It's not necessarily a "bad" thing (since the person may be being sincere and meaning well); but I think if the stranger is a woman, complimenting another woman, it's often seen as sincere and nice. When it's a man complimenting a woman, there can be a tendency for a lot of women not to trust that it's sincere. Even if it's sincere, though, there's just something about that that makes women kind of wary. Personally, I'd rather guys keep their compliments to themselves.
I was going to say if it isn't personal it makes a difference. For example, "You have great hair," (not good because it may be a line) versus, "That's a great car," (but even then, a woman is likely to think the guy is just thinking up something to say). Then there's something like, "Your little kid is such a well behaved little guy," (but that one might make a woman wonder if the strange man is inappropriately focusing his attention on her child).
I think the same kind of thing can apply to women who compliment strange men out of the blue, but women may be particularly cautious about strange men.
Sometimes there'll be a situation that makes it obvious that a stranger's compliment is obviously genuine. For the most part, though, just complimenting strangers out of the blue doesn't particularly go over well (I don't think) if the "complimenter" is of one sex and the "complimentee" is of the other.
Even when it comes to women complimenting other women, I think it makes a difference whether the setting is a place such a local store in a small-ish community versus the subway station or a restaurant at a rest area. (A lady at the local grocery store who tells another one, "I love that bag you have. Do you mind my asking where you got it?" is one thing. A lady in the subway station who pays a little too much attention to another's pocketbook might come across as suspect. LOL )