The situation with doctors and lawyers is considerably different however.
Doctors, whether MDs or otherwise, tend to be pretty well-compensated in US broadly.
Lawyers are much more of a mixed bag. White shoe law firms--mostly hiring students from top-tier schools with prestigious clerkships? Big bucks though either make partner or are mostly eased out. Some decent corporate law and successful private practices. But it's generally not a particularly well-compensated profession for someone from a mid to low-tier law school. And lots of people who graduate law school and even pass the bar don't actually end up practicing law.
Doctors are well compensated in large part because their unions (professional associations) restricts the number of new doctors unreasonably and advocates against certifying foreign doctors to practice in the US.
They also enjoy broad exemptions to antitrust law which would otherwise apply. It's why other classes of worker cannot have the same type of protective guild -- it's legal when the ABA or AMA do it and illegal when someone else does it.