Why would such examples be "frowned upon"? Because careful speakers/writers often place a high premium on consistency. The "disputed" usages you cite have an apparently paradoxical problem of grammatical number.
The government is always changing their mind.
If government is singular, which is indicated by a singular verb, then where do the (apparently plural) elements referenced by their come from? It's the same issue that causes some careful speakers/writers to object to "singular they" as a neutral pronoun with singular antecedent, even though it's been around and common for centuries and rarely creates confusion.
In certain contexts, particularly in written prose in a more formal style, this sort of linguistic analysis is easier to do than in fast conversation. In such cases, such inconsistency in number would generally be branded as "awkward" at best (and likely considered "wrong" by many). If I wrote a sentence like one of your examples, I would probably rephrase it to get my point across clearly, rather than simply changing the number of the pronoun (which, as I will argue, alters the meaning in some cases).
Why would the usage be acceptable? Well, mostly because the meaning is very clear in spoken colloquial English. In the above example, the government is not a monolithic entity: it is composed of individual people, who each have to make decisions. Nevertheless, there is some sense of a collective mind that is being changed in the idiom changing [his/her/its] mind. In this case, it may just take a few votes switching sides to move an issue for the entire government. Hence, the government (as a whole) will be changed (as a whole, in its mind) by a few voting members (they) making a shift.
It is perhaps overly concise, packing in a subtle reference to a collective noun's individual components while maintaining a sense of the change of the whole. Again, if I wanted to express that in formal prose, I'd reword it. Simply changing the sentence to
The government is always changing its mind.
does not fix the problem. Rather it alters the meaning to emphasize the monolithic character of the government, as opposed to the individual members.
The various examples given in the question pose similar issues, though I think the justification for the usage is less clear. Take the first example:
The class is working on their assignment.
Unlike the government example, what additional subtlety of meaning is given here by the incongruity of grammatical number? I can't really think of one, and this sentence actually sounds the most awkward to me of the examples given. I would tend to write
The class is working on its assignment.
though I can imagine someone saying:
The class is working on their assignments.
In that case, there is a mid-sentence shift in number from the emphasis on the whole (class is) to individual members and their individual materials (their assignments). A similar thing happens in the last example:
The Smith family is at the beauty parlor getting their hair and
nails done for the wedding.
In this case, it is somewhat nonsensical to say that a family has its hair and nails done, since families as entities generally aren't seen as possessing hair and nails. These are, rather, the possessions of individuals. Note also that here, as in my example of their assignments (and the question's example of their uniforms), hair and nails is plural. It's not as obvious, since even an individual has hair and nails, but I think the sentence would sound quite weird if we just pluralized the pronoun but not the noun:
The Smith family is at the plastic surgeon getting their nose done
for the wedding.
At a minimum, we'd need to change it to noses, assuming more than one nose was being altered.
And while we're creating absurd sentences, imagine:
The government is at the beauty parlor getting their hair and nails
Even if the government were [subjunctive! not plural] composed of a large number of people who all went off to the beauty parlor one day, I would argue that this sentence still wouldn't make sense. Why? Because "getting hair and nails done" is not a common activity of governments, and even if individual members might do so, it is not in any way related to governmental function. On the other hand, class members do do assignments, team members do put on uniforms, and family members often do go en masse to beauty parlors before weddings.
My point is that in all of these cases, a reference both to the collective whole and to individual members acting as individuals could make sense and hence might get thrown into the same sentence together. The less stereotypical the actions (and the shorter the sentence), the more awkward the usage becomes. To me,
The team is eating their lunches.
sounds more strange than
The team is putting on their uniforms.
Basically, I feel like there's a combination of "shorthand" synecdoche (team is just faster to say than team members) and mid-sentence correction going on in many of these examples. Careful speakers might actually interrupt themselves and start the sentence over with consistent grammatical number, but practical English speakers will just plow through and assume the shift in number is clear from context (which it mostly is in these examples). Meanwhile, they don't breach American speech protocols for collective nouns (The family are... sounds odd to Americans in most contexts) while gaining the benefits of concise speech that both references a larger communal entity acting collectively and also recognizes the individuality of its constituents.
But hey, don't just listen to me. Over at Language Log, a post from a decade ago addressed the issue (and specifically the word family). The argument there, as I tried to make here, is to consider the individual logic of the sentence and what multiple meanings it is trying to get across by changing number in midstream:
If someone's logically-concocted "rule" ... tries to stop me from saying
what I mean in this case, I perceive it not as a principle to be
learned and obeyed, but as a tyranny to be resisted.