Building Codes and Zoning are orthogonal concepts. Japan has more lax zoning than the US at large more more stringent building codes.
In "communism works because the cows are spherical, friction is 0 and gravity is 10" example land sure.
In reality building code is how a huge amount of back handed regulation is done. When the powers that be can't make a particular rule, because of other laws, or because of precedent to the contrary, or because the peasants wouldn't stand for it, what they do is they adopt a ridiculous code and then slap a "can be waived at the discretion of board X" on it. This way they can make the thing they don't like a non-starter economically for most people.
In my city you can park a semi trailer as storage. But it counts as a "structure" and because it's not a commercially manufactured shed, car port, stick framed garage or litany of other exemptions you have to go through the "everything else" process which includes all the "normal code shit" that any other non-exempt structure would hav to go through like an engineered foundation and snow loads and all sorts of other stuff that's just inappropriate. They have a similar set of BS they use to prevent DIYers from erecting kit buildings.
That's the simplistic view but not true in reality. Where I live the zoning law itself creates code exceptions -- for instance where I live my zone explicitly says there is no enforcement mechanism for codes, which effectively makes the building code (redefined as, essentially nothing) part of the zoning.
So zoning can turn de jure code requirements into de facto nulled or altered.