Dead or broken branches, or scars produced by fire, logging, pruning, birds or insects provide an entryway. Then, the right moisture levels, temperature, and nutrients have to be there. There are zillions of fungi that infect plants. Many are specialized pathogens that feast on one particular plant or tree species. Smut, known scientifically as Ustilago, has a particular taste for corn.
Corn smut is a really horrible looking black blob that grows right on cobs of living corn.
It's a delicacy in Mexico. Fungal infections can grow fast inside trees. Fruiting bodies do produce fruit, of a sort - they make more spores. These spores go on to establish new sites of decay. They're not always easy to see, either.