To build on the answers from @Armatus and @S-Sunil
The healing mechanism involves the inflammatory process, which is the same in almost the entire body. In particular in both skin and mucosa (both referred to as "epithelial" tissues), when there is a break, platelets and clotting factors clot off any bleeding vessels, white blood cells (neutrophils and macrophages in particular) collect and destroy any bacteria, dead cells and muck, and then the process of regeneration occurs (with ongoing inflammation), where stem cells in the surrounding tissue regrow cells, new blood vessels may be formed and scar tissue is laid down to give extra strength. Eventually after these stages of healing, there is "remodelling" where the structure basically gets better.
As to why oral wounds heal quickly and don't get infected that much? There are a bunch of reasons. One is that the head and neck has an excellent blood supply- just think of scalp wounds where you bleed like crazy but then they heal very well. Another is that mucous membranes have immune functions that stop invading microbes. Generally speaking we divide this into "innate" immunity which is a general response, and "adaptive" immunity which is tailored towards specific bugs. The mucosa has both. There are neutrophils and macrophages (innate) which live in that area, there are lymphoid patches (like lymph nodes, and adaptive), there are immunoglobulins specific to mucosa (IgA) which is adaptive in nature, and the epithelial lining cells themselves will signal to the rest of the immune system if there is damage or an infection. Plus, saliva itself has chemicals and enzymes which break down oral bugs.
Most of the oral bacteria themselves are not particularly invasive. Just think, every time you brush your teeth, you cause multiple abrasions in your mouth. In fact, measurable amounts of bacteria from the mouth end up in your bloodstream every time you brush your teeth! And yet, we don't end up with bloodstream infections as a result. This is partially because the rest of our immune system (and the structure of our heart and vessels) is intact, and partially because oral bacteria are not very invasive or pathogenic. They kind of have a sweet deal living in your mouth minding their own business and not killing their host, and even causing infection in an oral wound would make their continued survival less likely.
In addition I should probably point out that skin has a great deal of bacteria on it as well, and yet we rarely get infections from them (unless colonised by an invasive species), for the same reasons.