With agile, practically, many times development is just in time with little regard to long term requirements or the evolution of software so it's all layers of layers of things that work. There's rarely a time for fundamental restructuring of the codebase to meet the new requirement correctly.
Once the cracks begin to show, we start thinking of software rewrite.
For a construction of buildings, the redevelopment is about once 40 years, for software, it's about 5-7 years.