Management likes to reduce risks by treating developers as interchangeable widgets.
The silly approach which has been introduced as a revolutionary, agile “achievement” expects that all developers are familiar with all areas of code. The goal is to minimize the loss when any individual leaves the team.
Well, this is the worst possible way to approach software development.

First and foremost:

why does the management think that programmers are going to leave the company?

If people are indeed leaving the company, then this is the issue that must be fixed. And expecting that all developers can be experts in all areas of a huge codebase is just as silly as believing that any software development methodology is a cure for the core problem.

Your employees are supposed to like working for you, so turnover should be low. Developers leaving should be an uncommon scenario. If this isn’t the case, the management should rather think about what they are doing wrong – rather than coming up with false expectations and “wonder-methodologies”.

No SCRUM or Kanban can fix the incompetence of the management.

Going back to the original issue: instead of expecting that every developer is mastering all areas of the code, they should rather be assigned as owners of particular portions of the codebase. This approach is way better, which not only gives developers a sense of empowerment but also prevents inferior changes to go unnoticed. Because primary code owners won’t let this happen. They are the ones who know best why and how the given code or component is working. They have been actively participating in the development of those code parts, and they will catch most dirty hacks/whacky implementations and push back low-quality code right away.

Because an owner always defends her property; however, if there is no responsible, nobody will care.