I made this post with a genuine interest in learning and improving ... I've never been rude or offensive to anyone by literally saying "your haircut looks great" and moving on to other things in my day.
Without getting into larger politics - I think the point that was made above that the feedback you're getting from people - that you're sensing 'an increase in tension' - tells you most of the answer. You're clearly empathetic enough to have noticed that. I don't think it means you can never give compliments, but that they should be different ones or reserved for closer friends/family.
Personally (as a Canadian who has travelled and lived abroad extensively) - this is normal stuff in adjusting to a different culture and society (and indeed a changing culture and society - it's not static). The lines of what are appropriate or somewhat over the line or contribute to an unhealthy tension are sometimes very subtle and require some adaptation. They differ by context (social, work,, age group, etc) and so can be somewhat hard to negotiate. What's considered simply social flattery vs flirting (and when flirting is appropriate) is not something to which a straight answer can be given. As is perhaps obvious, even positive comments on looks are just not the norm now in many contexts.
I found (surprisingly perhaps to some) the USA to be challenging in this way - perhaps because I assumed it was very similar to Canada and it wasn't (at least in this regard) - much higher sensitivity/offense taken than in Canada, so I adjusted. That said, some of this is exaggerated - I still hold doors for all ages/genders and have never had an issue or a negative reaction.
A parallel some
might find useful - I've been exposed to swearing in many languages, and one consistent thing is it is
extremely difficult for non-native language speakers to judge exactly when swearing is acceptable or called for. Of course native speakers can get it wrong too, but it's just that much harder to judge in advance if it's not your mother tongue - non-native speakers just don't have the feel for how strong the words are. (A friend's immigrant mother found all English swear words innately funny, but never, ever swore in her native language - they were all unthinkable for her to speak out loud; she naturally just did not feel the strength/relative strength of English swear words).
My simple rule for myself is that I try to avoid swearing in other languages, or only in contexts (close friends for example) where I know I will be given some leeway. If in doubt, erring on the side of caution is almost always preferable. That's not because swearing is universally forbidden in those languages, or more 'prudish', etc - it's just different social cues that I don't feel in the same way.
This is only an analogy/parallel so of course imperfect. But extra caution when uncertain is a relatively easy rule to follow.