Yes, you take out loans, invest in getting an education to hopefully succeed in becoming a doctor, then you start making more income to repay the loan.
Same thing with any business venture.
How do you start an ice cream parlor? Does anyone actually pay for their own startup? Well, if you don't have the disposable income already, you take out a loan because you are counting on yourself that you will make a successful business, then when you start earning profit, you repay the borrowed money. Makes sense.
But there is risk to opening up an ice cream parlor -- you might fail and not make it, but that can occur due to a myriad of other factors. Your ability to fail and not repay loans in optometry school can only occur if you 1) can't count on yourself to pass, and 2) job market conditions where you aren't a competitive applicant for jobs. However it looks like you would have more control over your risk paying back an optometry loan because it's based on your ability to not fail school, and you can do that right? Because if that risk does occur, not only did you lose years of potential employment, you also have no capital to repay back the loan (whereas the bankrupt ice cream parlor can at least sell their assets to recoup some cost).
It would be a tragedy to take out hundreds of thousands of dollars in loans only for it to disappear because of the inability to cut it in college. Don't let that happen to you! Make good choices!