Statements like these seem like compliments but they are often loaded with assumptions about a person based on their race or ethnicity such as their intelligence, whether or not English is their first language, or what their speech should sound like. In these examples, the person on the receiving end of the statement likely didn't fit the other individual's stereotype. It's better to make a compliment about the content of what someone is saying vs the ways in which they are saying it.