Yep, it's a huge risk. If a student enters medical school and realizes halfway through that they don't want to be a doctor then they're still stuck with a huge debt and no way to pay it off. It's not like undergraduate education where you can fairly easily switch majors from chemistry to mathematics or whatever.
There are arguments that these are factors that filter out the people who are not sufficiently motivated, but it's hard for me to imagine there aren't a lot of bright young people who might be interested in medicine, but see one of the various paths that exist today to making doctor-level money with only an undergraduate degree and in an environment that doesn't require a working schedule that actively harms your health.