You'll find a lot of people trapped in homes they cannot sell. The cost to update very old homes would far exceed what most people can spend out of pocket, and by the time they paid off the debt to do so, the codes may have changed again.
Also, older couples who have lived in one place many years and are now retired generally cannot take out lots of money. Instead of being able to sell and move to a senior community or nursing home, they would be stuck with a property they cannot maintain, compounding the problem.
Essentially, you would be hurting vulnerable people at the advantage of the young and wealthy.
If the updates were mandated as the code changed:
See all of the above, but now you're forcing people out of their homes even faster.
I agree there are challenges in both having homes that appreciate and homes that depreciate.
In the US ex post-facto laws are generally unconstitutional. Our law defaults to grandfathering (there are exceptions), so a change in code applies to new construction, or renovations to existing structures. My experience owning older properties is that this was not a feature. Often what would be a repair in a new property would lead to a major renovation because whatever was being worked on would have to "be brought up to code".
Here are a couple examples showing both an ex post facto change and a non-ex post facto change.
Example 1: The building code is changed to say that all electrical outlets installed in kitchens must be installed with GFCI protection. Your non-GFCI kitchen outlets were installed before this change. In this case fining you for not having GFCI outlets probably would violate the ex post facto law prohibition because you are being fined for something that occurred before the new law--the installation of non-GFCI outlets.
Example 2: The building code is changed to prohibit non-GFCI outlets in kitchens. Your non-GFCI kitchen outlets were installed before this change. Fining you for having non-GFCI outlets would probably not violate the ex post facto law prohibition because you are being fined for something that is happening after the law--having non-GFCI outlets in your kitchen.
(This is all assuming that fines for building code violations are punitive. The prohibition against ex post facto laws in the US generally only applies to changes that increase punitive aspects of laws).
My personal experience having owned multiple properties is that code changes rarely, if ever work the way you are describing. I've actually renovated a few kitchens, and had to deal with GFCI because the law around the permit for construction required us to, not because the code change was applied to pre-existing non-GFCI outlets. It would be impossible to maintain a property if the law worked as you described - the government could declare the kind of shingles on your roof illegal, and take your property for non-compliance, which is exactly why ex post facto laws are unconstitutional.
But what if they did? What if our governance said old homes must be updated? Then old homes would probably be worth less because it costs a lot to retrofit sometimes.
I may have some or many of those details wrong, just thought it was another example of how political decisions drive housing prices one way or the other.