That's a lot of benefit of the doubt to give. More likely is that they know exactly what they have, and have done the math. For every salary level, there is a probability P that the employee will leave. If it costs $C to replace them, then they are coming out ahead by paying you $N below market rate when N > P x C.
EDIT: To be more exact, it's probably more like: N > [P(N) - P(market)] x C
First, the cost of a valuable employee leaving is very, very high in terms of their salary. The inefficiency in training someone to fill their shoes is awful and risky, and good engineers are seldom fungible in any short-term meaningful sense.
Second, this isn't how decisions get made on real-world software teams. In the real world, you find yourself just working with managers who need to make judgment calls with limited resources and time. Pursuing a raise for an employee is expensive to do proactively. A valued employee leaving sends a manager into crisis management mode, which expedites the process and helps them prioritize it up whatever chain they report to. The manager (+chain) make a judgment call about whether to make you a counter against a backdrop of company policy.
Their failure to proactively get you a raise before you went seeking other opportunities is usually due to a failure of communication, timing, or time budgeting on both your and their part. You can't expect people to read your mind and figure out if you think you're being paid what your time is worth. Sometimes it's obvious (oh look, the last of X's stock grant just vested), but usually it's not.
Your suggested envelope math might help inform general company policy, but it doesn't inform day-to-day managerial decisions in any but the vaguest way. Most management I've worked with has not been formally sophisticated; I imagine this is the case in the industry broadly. Managers do not wake up in the morning and consciously wonder "what do I need to do today... hmm... does the marginal utility of working on a raise for X exceed the marginal utility of writing this operational improvement plan?" They think "Is there a crisis? If crisis, expedite. Otherwise check shit off checklist."
I told my most recent manager I was pissed off about my salary a few months ago (after a year at the company). He got it kicked up the chain, I got up-leveled at the next review session. It took him a lot of time and effort, it netted me a large salary increase. I think we're happy with each other still.
EDIT: To be more exact, it's probably more like: N > [P(N) - P(market)] x C