A recent weblog post going over the history of this starting back in ~1200:

> However, the term “doctor” wasn’t usually used to speak about those who subsequently went on to work with patients in the field of medicine. Why? Well, the term “doctor” comes from the Latin verb “docere” meaning to teach. So, if you were called a medical doctor it meant that you were teaching at Salerno, not that you were out in the field actually doing the stuff you were trained to do.

> The people who got trained at Salerno, took their degree, and went out into the world to practice medicine needed a title which made it clear that they were not university professors, but university trained, so that people knew what their job was. And they had one – they were called physicians.

[…]

> In English the term “doctor” didn’t start being used to address people with medical degrees until the seventeenth century, and it began more particularly in Scotland. Funnily, the use of the term was meant to confirm respect to the doctor confirming that, yes, they were very smart indeed. Yes, that’s right – they were as smart as all the people with PhDs, bless them.[8] The medical people were trying to catch up with the humanities people because everyone knew that it’s really hard to get a PhD and it confers authority. This took off because everyone post-enlightenment absolutely loves to crank themselves about how important Science is, or whatever. The fact remains however, that it is a relatively new occurrence.

* https://going-medieval.com/2023/11/29/doctor-does-actually-m...

Strictly speaking, in the original usage, you shouldn't be calling yourself a doctor unless you have doctorate (degree):

* https://en.wikipedia.org/wiki/Doctorate

The medical folks should probably be called physicians:

> Doctor of Medicine (abbreviated M.D., from the Latin Medicinae Doctor) is a medical degree, the meaning of which varies between different jurisdictions. In the United States, and some other countries, the M.D. denotes a professional degree. This generally arose because many in 18th-century medical professions trained in Scotland, which used the M.D. degree nomenclature. In England, however, Bachelor of Medicine, Bachelor of Surgery (M.B.B.S.) was used and eventually in the 19th century became the standard in Scotland too. Thus, in the United Kingdom, Ireland and other countries, the M.D. is a research doctorate, honorary doctorate or applied clinical degree restricted to those who already hold a professional degree (Bachelor's/Master's/Doctoral) in medicine. In those countries, the equivalent professional degree to the North American, and some others' usage of M.D. is still typically titled Bachelor of Medicine, Bachelor of Surgery.[1]

* https://en.wikipedia.org/wiki/Doctor_of_Medicine

> Even though the M.D. is a professional degree and not a research doctorate (i.e., a Ph.D.), many holders of the M.D. degree conduct research and publish in journals during training and after graduation. Combined medical and research training is offered through programs granting an MD-PhD. […] The United States Department of Education and the National Science Foundation do not include the M.D. or other professional doctorates among the degrees that are equivalent to real doctorates.[68][69]

* https://en.wikipedia.org/wiki/Doctor_of_Medicine#United_Stat...

(But here we are.)