You don't "catch" oral thrush; the yeast is already there. A number of factors can increase the chance of the yeast growing out of control. The leading cause of oral thrush is overuse or prolonged use of antibiotics.
Yeast must compete with various other organisms, many of them bacteria. These bacteria, which live on the skin and in the intestine and vagina, among other places, are harmless but good at fighting off yeast. When we take antibiotics to deal with disease-causing bacteria, we kill the harmless bacteria as well. Yeast, which is unaffected by antibiotics, is no longer controlled by the bacteria and starts to grow and multiply.
Steroids and some cancer medications weaken the immune system and can also allow yeast to flourish. Oral thrush most often develops in people with diseases that weaken the immune system, such as cancer and AIDS. It can also develop in people with diabetes or in people who have long-term irritation resulting from dentures. Some medications can also change the environment in the mouth, causing the yeast to grow out of control. A common culprit is inhaled corticosteroids - medications used by people with asthma or chronic lung conditions.