Not all lawyers and doctors are the same. Consider public defenders. And physician compensation can vary dramatically depending on whether they're a general practitioner or specialist, rural or urban, etc.
Ironically, the ones we need the most are paid the least.
Of course, that's assuming students finish their degrees and get jobs. Plenty of people drop out of school, and they don't get refunds! Law students fail to pass the bar, etc.