It is well known that the best way to get a raise in software is to switch jobs. It is well known that the market is hot. It is well known that tech tenures keep falling.
So why is nothing done about it? Why does the best way to get a raise remain switching?
All I can conclude from the lack of corporate action on turnover is that we are pretty interchangeable and domain knowledge and codebase knowledge aren't considered to be worth anything.
Corporate complains about knowledge loss, delays getting people started on the codebase, the cost of paying recruiters, etc, but their actions price all of that at $0.
From a (large) corporate perspective, some turnover is fine. In fact, it can cause problems if it drops too low. It's hard to put an absolute figure on it but we find that below 10% or above 20%, for an extended period, causes problems. If it's too high you get the issues you describe. If it's too low you get stagnation, difficulties with promotions. That sort of thing.
Some organisations go so far as forcing some percentage to change annually. Typically that's around 10%. I don't subscribe to that approach personally but it's a result of the notion that turnover can be too low.
It's also not generally true that companies don't value domain knowledge. It might well be true they don't value it as much as you do but it's always been a significant factor in compensation decisions that I've been involved in. Codebase knowledge, on the other hand is usually a second order factor as best. Unless the codebase is "special": the Cobol general ledgers of this world.
Your point on switching companies as a good way of getting raises is valid though. There's a few things that underpin this. People tend to be sticky in their jobs, flipping is effort, and companies definitely (ab)use that fact. There are other factors. Hiring often occurs because something needs doing sooner rather than later. That opportunity cost can affect the calculus of hiring cost vs waiting cost.
Source: reasonably senior manager in a large corporation.