A fungus is not a plant and not an animal. It is a network of filaments — hyphae — that grows through soil and wood, fusing with the roots of the trees around it and trading sugar for minerals. The visible mushroom is the fruit; the organism is the several hundred kilometres of thread under your feet.
Each growing tip is a decision made four or eight times a second. If there is more food in one direction than another, the tip turns towards it; if not, it goes straight on; and every so often it splits, which is how the network becomes a network rather than a thread.
There is no brain, no plan and no central control. The pattern that emerges — a fan of veins fanning out from a source, thickening where food is abundant and thinning where it is not — is the accumulated sum of those tiny local choices. It is the same reason rivers make the same shape, and the same reason the branching of a lung looks like a tree.