You're right, but the reason that doesn't happen is that the price (ie, expected future earnings) is effectively fixed[0], and the current trajectory of that is already on the threshold of discouraging people from entering the field. As it is, a person who enters medical school at the age of 22 can reasonably expect to pay off their final student loan payment in their 40s[1]. That's a pretty hefty gamble to take at that age - you're assuming (against all evidence![2]) that medicine will continue to pay roughly the same in the future as it does today, and based on that assumption, you have to be willing to take a gamble that won't even break even until you're past normal childbearing age. That's a really tough sell, and I say this not hypothetically, but from experience.
It's similar to the "engineering shortage" in Silicon Valley - we know for a literal fact that the largest companies colluded to suppress wages, but simultaneously complain that they can't find enough workers that price. Except, we don't have to take out large amounts of debt before we can start working, whereas would-be doctors do.
[0] Not exactly fixed, but far from an actually competitive market that would allow proper consumption smoothing like you describe
[1] There are a lot of factors that determine this, like which specialty you choose, and where you practice, but that's a pretty reasonable rule-of-thumb estimate for someone who's still only thinking of applying to medical school in the first place.
[2] Physician earnings have been dropping steadily over the last few decades
With that said, why do you say doctor wages are fixed (and forseeably so)? Is there a variance in pay and legit competition for doctors and so on?
Also, I don't see why the long loan repayment period or anything else suggests doctor wages are hitting the "too low to get people into the field" level. Remember, there are still far more qualified people than med schools are willing to accept, which means there's still excess supply (in the sense that there isn't in SV tech labor).
Plus, being an MD has a level of prestige that doesn't show up in the wage, and which has numerous fringe benefits (like easier loan terms, since they know you'll probably always find employment).