This applies to my area, I don't know about others.
Updates are mandatory, but there is a bit of a grey area there, too.
If an old 3.5gpf toilet is repairable, it isn't mandatory to replace it as long as it still functions as designed. Now if I get a refurbished 3.5gpf from my garage that I've been saving for a rainy day and replace the existing toilet with it, then I'm in violation of the water conservation act.
The federal govt. also stepped in and made certain things mandatory from a manufacturing standpoint. Examples, all gas fired residential water heaters manufactured after 2004 shall be FVIR tanks. All toilets 1.6gpf or less, reduced lead in faucets. The list goes on.
On water services, any time an old water service is replaced or repaired connecting to the meter, backflow devices must be added and pressure regulated if 80 psi or higher.
This is something to think about when a plumber comes into your house to replace a faucet, toilet or HWT and states "It's the law that I have to add a backflow and a regulator to update your house to code, or I can't do the work and I'll have to report you." Not true.
There are usually local provisions to protect homeowners from having to spend thousands of dollars for basic service repairs and updating. Home inspectors forget this when evaluating homes and try to apply new construction inspection standards to the inspection of a 50 year old home. Can you imagine if before any home could be sold, it had to meet modern code standards? It would cost somebody tens of thousands of dollars and they could never recoup the costs in the sale.