Having to rewrite existing features differently is mostly a consequence of you not being an expert in the business application you’re writing.
Maybe if you’d invest more time upfront to understand deeply what the application is for and how people are going to use it, you’d be able to spare a few mistakes.
But even being an expert and talking to people doesn’t shield you from that problem. There is always a new feature that contradicts how the code works. It’s just a consequence of software being so malleable.
As a car driver, you can’t ask the car maker: “hey can the needle on the speedometer turn red when I go over 60?”, or “hey I need this car to work with both gas and diesel?”
This would be perfectly reasonable in a software equivalent world.
In the end, you just need to explain this to your client…