As @Espiritus_Corvus has alluded, there are several tree species, including mangrove and banyan and others that grow naturally to have exposed and protruding roots. In some cases, I think, the root goes underground and later protrudes through the soil again to grow into a new tree – obviously not independent of the parent tree. So it’s not only a way to nourish, but also to propagate. This seems to happen more often with trees that grow in or near swamps, where the exposure of the roots to air some or all of the time keeps the tree from “drowning”.
In other cases, such as trees that we’re familiar with from temperate and land-based locations, storms and other erosion causes can wash out the soil from a mature tree’s roots. If left unchecked, that will frequently kill the tree as it fails to root deep enough to find water (which evaporates more quickly from near the surface of the soil), or simply failing to anchor the tree sufficiently, and it topples and dies.
Of course, there’s also landscaping, bonsai and other deliberate human acts to create effects with living trees and other plants, some of them more artful (and successful in terms of long term survival of the plant) than others.
I would also like to correct one misconception about evolution, which does not “figure out” anything at all. According to what we think we know about evolution, “chance mutation” occurs from time to time in “child” organisms, and the chance either improves the new organism’s chance of propagating its own genes – or not. If the change is successful in biological terms, then the new organism is “more able” to pass on its genes to succeeding generations of the species, and over time its progeny may overtake others of its species and then become the model for the species over a period of many years. Otherwise, the “original” species is able to survive perfectly well, but the mutated organism’s descendants manage to survive in a somewhat different environment and over time become a different species.
There is no “figure out” to it. Some mutations that would seem to make sense simply do not occur, because the succession of mutations that would be required to achieve the change never happen.