Mario studied medicine in college, but decided to become a carpenter instead (before switching to plumbing).Shigeru Miyamoto has hinted that the Dr. Mario games don't count as part of the (implied) canon of the Mario series. It could be said however, that Mario, and maybe even Luigi might have studied medicine when they were in college, but simply decided not to become doctors. Admittedly though, this doesn't explain Princess "Toadstool"note being a nurse (according to the instruction manual for the U.S. NES version).
The Dr. Mario series takes place within an Alternate Continuity, completely separated from the mainline Mario games.In Dr. Mario's universe, Bowser never rose to power or was defeated for good. This might explain why we never see Bowser in any of the Dr. Mario games. Since Peach was never or stopped getting kidnapped, Mario didn't have a need to venture out to save her. He decided to take up medicine to fill his time.
Mario is simply dressed as a doctor as a part of a plan to get rid of the viruses, which are monsters, not actual viruses.It's been established that "Dr." Mario isn't a real doctor, and Mario isn't the sort to perform back alley medicine, so, clearly, something else has to be going on here. The Mario & Luigi series shows that viruses are monsters, not literal viruses, though they may be related to actual viruses. There was an outbreak somewhere, and Mario disguised himself as a doctor and used the "pills" to exterminate them.
Wario created the viruses.Assuming Dr. Wario is canon, Wario also became a doctor and wanted to make tons of dough, so he bioengineered the viruses to draw patients to his clinic.