Medicine is 4 years undergrad (in which an aggressive pre-med curriculum must be completed in order to be considered for admission to med school) + 4 years med school + 1 year residency (9 years), and if you're becoming a specialist, throw 3-5 more years in there for extra classroom time and an extended residency. Also bear in mind that this is just formal schooling; these totals don't include the time needed to prepare for specialized entrance exams like the MCAT. It's excessive.
As for law, most non-US jurisdictions allow attorneys to practice after 5 years of training and the receipt of a LLB degree, whereas the US typically requires the full 7 years and a JD. Just another way the ABA is protecting the American public.