Dentist found a papiloma on my gum and told me it was like a wart. How could I get this?

Papilloma. Very common and there are 100 different strains of this virus all classified by the general term hpv. Did your dentist biopsy the wart or refer you to an oral surgeon? When on the gum most commonly a fibroma of connective tissue origin and has a cauliflower appearance. Hope this helps.
It's viral. Like all wart-like structures, it's viral in origin. It's perfectly benign. Talk to your dentist about removal...Fairly simple.