To my (admittedly layman) understanding, they're sort of life's premiere resource extractors. Their whole thing is breaking down things that other life can't, so it's not surprising at all that some species can consume oil.
We know they co-evolved with plants, and one theory suggests that fungi allowed plants to make the jump from water to land by using their hyphae to act as a proto-root system, unlock nutrients like phosphorus from the soil, and transport water, while early land plants provided sugars produced from photosynthesis in return.
One of the main differentiations that might have led to the split between proto-fungi and proto-animals is their nutrient acquisition strategy. The organism that would become fungi had extracellular digestion, while the organism that would become animals captured and ingested other organisms.
This split led to different approaches to cellular adhesion along with different developmental and signaling pathways (different strategies for achieving homeostasis for instance).
---
If you want to read about some really wild stuff, look up the Late Paleozoic era in the Carboniferous period. Basically plants evolved Lignin (wood) but there was nothing in the world that could break it down so it rapidly accumulated along with a hyperoxgenated atmosphere due to the extensive growth. This meant there were 8 foot long millipedes and dragonflies that size of crows flying around. There were also massive forest fires spanning the globe since fire was one of the only ways to get rid of the lignin until, eventually, some fungi evolved to take care of the problem.