In other words, teachers are not willingly giving up a portion of the compensation that they could otherwise be making doing the same job somewhere else. In software instead, that happens ("Oh, you work on FOO v2.0, I'll happily take 40% less than what I could otherwise be making doing this job in another company").
I don't know about public defenders, you might have a point there.