Buildings don't decide anything, building owners do. The problem is that without building codes, building owners are incentivized to not make buildings earthquake safe: no one short of a civil engineer doing a tear-down analysis can figure out on their own if a building is earthquake-safe, which means that no one does, and everyone rolls the dice. Since earthquakes are rare, it's quite possible that the original builder will never be exposed to the results of shoddy building practices. However, it is guaranteed that someone will be. So we have a situation where the risk analysis is very difficult if not mandated ahead of time, the event is rare for a particular individual but guaranteed for a population, and the cost up-front for an individual is fairly large. The rational calculation for each individual builder is to not make it earthquake safe, and just claim it is ok. This shifts cost from individual builders onto the population at large.
Building codes are essentially the general population saying to individual builders "we made our risk-benefit analysis, and we're not going to subsidize you."