I don’t think “anyone” wants to rewrite their code (or someone else’s for that matter).
But sometimes you have to because whatever it is that is being asked of you cannot scale in what you have built.
That’s the Software game, sometimes you need to rebuild it and start from scratch.
Housing and construction are often compared to building software with many of the same phrases being interchangeable.
The same applies to a house, if the changes are so significant that the entire house is liable to change or the current foundation cannot support it, you guessed it – time for a rewrite.