Just want to expand on that "tuition/debt/time" bit.
TL;DR: Becoming a physician requires sacrificing an additional 6-10 years of your life to education and training beyond what you'd expect for most careers, and assuming something like $250K in additional debt. It'll take the average physician about 16-years out of college before they start to out-earn the average engineer.
Details:
Let's imagine that two smart people start college in the United States. One goes into engineering, the other into med school.
The day they graduate, on average the engineer will get job that pays them $74k their first year.
Year 4, the engineer is likely making $84k/yr, and they have earned a total of about $315k in their career.
Meanwhile, our doctor friend has so far accrued about $250k in debt. A delta of about $560k in just 4 years, but it's gonna' get worse before it gets better.
For the next ~3-5-years (for most specialties, there are outliers), our doctor friend is gonna make about $50k/yr . (Yay, positive cashflow!) We'll generously assume their debt doesn't accrue interest in this period.
Assuming our engineer friend assumes an average career path, he's gonna be up to $92k/yr at the end of this period, with a lifetime total earnings of $669k, while our doctor friend has clawed their lifetime earnings all the way back up to -$52k.
This is also the biggest delta between the two careers. At year 8, our engineer friend has out-earned our doctor friend by a delta of $720k.
Now, on average, our doctor friend starts making $202k/yr. Good money, right!
To make the math easy, we'll assume that their debt still doesn't accrue interest.
With all that, it's not until 16-years out of college that the average American physician will start to out-earn the average American engineer.
So if they both graduated at 23, our Engineer friend is gonna out-earn our doctor friend until they both hit just about 40.
Of course, if our doctor friend has to pay some interest on their med school debt, and our engineer friend is able to invest a chunk of their salary in those early years, the magic of compound interest will be on their side as well.
And that says nothing of the fact that our doctor friend probably had to sacrifice about 4-years of mandatory 80+ hour work weeks. It also assumes that our doctor friend doesn't drop out/fail out of med school and manages to match to and complete a residency. None of which are givens.
Which is a very long way of saying: physician compensation is wonky because it's a career where you sacrifice a ton and take a ton of career risk very early on, for the promise of higher compensation and quite high job security later on in your career.