I think the issue is that there isn’t an agreement on your worth. If you’re willing to leave, your employer would pay you that higher salary if they truly believe that’s your worth. I also think it’s not correct to frame it in terms of what it’s worth to you (my coworkers, my knowledge, my job). That isn’t particularly relevant. What matters is how well you solve a particular set of problems and how important those are to the organization.
What I think is a more interesting question is why is there such wide discrepancies between companies regarding a specific employee’s worth?
Because nobody knows how to quantify the benefit that an engineer brings to a company. It is, in most cases, impossible (or at least excruciatingly difficult) to put even a rough dollar amount on the worth of a knowledge worker. Because of this, companies tend to use very vague strategies for coming up with offers, like "the lowest they'll accept", or "X% below the maximum we can afford". In those cases, the numbers will vary wildly depending on the company's budget, the subjective "value" that they put on knowledge work, and the negotiation skill of the candidate.
The reason most companies don't pay FAANG salaries is largely some combination of: 1) they don't have the money; 2) they objectively get less value from those skills; 3) they subjectively don't put as much weight on the skill set (think "sticker shock"); 4) they low-balled their first few engineers and nobody asked for more. I'd bet that last one is more common than you'd expect, especially with junior devs who don't know how much they could be making elsewhere.
Do you feel like this problem is unique to engineers?
I can see how other positions like sales can be more quantitatively measured in terms of contribution but my hunch is that many positions fall into this area of nebulous value estimation.
Or perhaps is more pronounced in software because of the amount of margins these companies work with
I think it's mostly unique to knowledge workers, which is a broader category than just software engineers, but does not include most jobs. I think the effect is more pronounced in software engineering because of high demand, as well as the margins for software, like you mention. (Anecdotally, I have seen the same effect with friends in other industries, like electrical engineering and chemistry, just to a lesser degree.) With that said, I think it's significantly easier to put a monetary value on, say, an HR person or office administrator than an engineer or scientist.
There is also the issue that the value of two different knowledge workers, even at the same company, may be wildly different depending on their specific skills and the project they are working on. For instance, someone working on product features at a software company is much more valuable than someone maintaining an internal reporting tool, even at the same company and even if their skills and the type of work are nearly identical.
The point is, there are a ton of variables at play here, most of which can't really be measured, so everyone plays a guessing game to determine what engineers are "worth". The asymmetry of information also doesn't help, because it's hard to know how much you could make if you don't know what anyone else is offering—many people take salaries well below their potential and don't even realize it.
What I think is a more interesting question is why is there such wide discrepancies between companies regarding a specific employee’s worth?