Zoning code != building codes. Zoning deals with the types of buildings/uses that can be built in an area not the requirements for safety like electrical or structural building codes.

It's definitely a mixed bag though, zoning keeps industrial uses away from residential which is good for pollution and noise reasons but it also restricts building dense housing in areas zoned single family.

I'm always dubious about explanations that don't account for the fact that the weather in many California towns are more pleasant and survivable year round compared to Texas. Or that locations like SF are quite space constrained when it comes to new housing so new projects generally have to displace some current use making the process harder.