Why do ulcers occur in the mouth?

Many reasons. Inflammation of the oral cavity can lead to ulcers. One of the most common irritants is acid. Coffee, tea, citrus can lead to an acidic state in the mouth which can lead to breakdown of tissue and ulceration. Even some toothpastes can cause irritation. There are also some systemic diseases which have oral ulcers as part of the symptom complex. Sometimes a biopsy can be helpful.
Don't know. Some may be autoimmune and I wish they were preventable. Herpes ulcerations can occur upon initial exposure. Frequent recurrences or a lasting ulcer should be evaluated by your dentist.
Many reasons. You really should get this checked out by your primary care doctor, then consider further evaluation with an oral specialist who could perform a biopsy. Oral ulcers range from very benign to being the initial manifestation of very serious systemic diseases. Be safe and get it checked out.