Usage of apostrophe in “baker’s dozen”
Because the dozen isn't the collective property of all bakers, but of a generic baker. It's the same reason it's a carpenter's square, a driver's license, a sailor's cap, a potter's wheel, or a greengrocer's apostrophe.
You see both farmer's market and farmers' market because there are several farmers selling at a farmers' market, so you can also think of it as a market that collectively belongs to these farmers.
It is a particular "dozen" of a particular person, an individual baker — it is the "dozen of a baker," 12+1 items. The phrase is not about a group of bakers coming together to count out a dozen, or about the total number of "dozens" of the n bakers in existence, which would be (12+1)n items.
I have heard the label genitive of source applied to this construction; the 's indicates an origin or dependency which affects the meaning of the phrase. It is actually quite common in English: we may say it's a man's world but never it's a men's world, even though the former could be interpreted as saying the world belongs to an individual man. Consider expressions like soft as a baby's bottom (not babies' bottoms) or rare as hen's teeth (not hens' teeth). We wear soldier's caps, collect a day's pay, and live a dog's life.
If you know the origin of the expression you realize that the "dozen" belongs to the occupation of being a "baker" rather than to an individual baker.
So "A baker's dozen" should be understood as A + (baker's dozen) where "baker's dozen" is seen as an expression meaning thirteen rather than as (A baker)'s dozen.