[Crosspost]
Further to joanne's and ABCDPuppies's replies;
You're right in that you should be pretty selective about these buildings, at least in the early and mid game. Later on, with so many

multipliers (Forges, Factories, Power Plants, Corporations, etc.) those hefty price tags for getting up the Market or Grocer become pretty mild.
Theoretically you've specialised your cities, and Markets and Grocers can be well suited to cottage-rich sites. Better yet, cities that have worthwhile shrines, corporation HQ's, and Wall Street.
Hybrid cities (mix of

,

, and

) with rampant unhealthiness or unhappiness that can't be addressed effectively by other techniques (e.g. the whip) could well qualify for these buildings.
The Romans get the Forum as a replacement building for the Market, and this should go in cities that are serious about popping

s, as well as natural

sources.
Likewise, the Persians get the Apothecary, which is well suited to any city on the fringe of

.
Also, consider your resources base. If you happen to have access to several of; Fur, Ivory, Silk, or Whale, whipping out Markets could quickly pay for themselves in that the whip unhappiness is countered by the happiness derived from Market-friendly resources.
Grocers are prerequisites to Supermarkets - so again,

affected cities, and those who are growing with optimal tile use at +1

might well benefit from the benefits of a Supermarket. The extra +1

could lead to another specialist citizen. If you get well into the Industrial Era,

is likely to be increasingly problematic, so the Grocer and Supermarket present themselves as one tool to offset your Factories and population filth, etc.