Evolution is not planned. An organism does not evolve because of a want or a need. Evolution is not organisms adapting to their environment. Evolution is gradual and is looked at through generations, not individuals, and within populations of the same species.
The evolution of plants is the same as it is for animals. Like animals, plants have genetic traits which provide them with advantages over other plants. Take for example the Giant Hogweed and its toxins it produces which can cause people who brush up against the plant to get second degree burns. The toxins produced by the Giant Hogweed was not by choice. The Giant Hogweed shares a common ancestor with carrots and parsnips. A heritable mutation for this toxin gave the plant an advantage to defend itself against herbivory. This allowed the plant to survive and pass on this advantageous heritable trait to its offspring. Eventually after thousands of generations we get the Giant Hogweed.
Maybe because we have anthropomorphized plants and animals we have made evolution a little more difficult to understand which has led to many misconceptions. “Since plants can’t run off to look for a mate and reproduce, many have evolved elaborate mechanisms of pollination — often cheating or bribing animal pollinators into doing the work for them.” This statement from evolution.berkeley.edu uses the terms cheating and bribing which are words we relate to humans more than we do to plants. Plants do not know they are cheating and bribing pollinators.
Pollinators can be birds, flies, bees, butterflies, and bats. We most commonly think of plants providing the pollinator with the reward of nectar in return for carrying the plant’s pollen from plant to plant spreading its genetic diversity. Some plants offer no such reward, but they too need their pollen transferred to other of their kind. Some plants, like the corpse flower, attract flies because they smell of rotten meat.
There is a species of ginger which attracts a very unusual pollinator, the dung beetle. This plant’s flower smells of processed dung attracting the dung beetle. Dung beetles are thieves and will steal the processed dung balls of other dung beetles. Thinking the flower is a processed dung ball the thieving dung beetle travels flower to flower looking for a dung ball to steal and unknowingly is spreading the pollen for the ginger plant.
This ginger plant did not choose to smell like a processed dung ball. Thousands of generations ago a possible heritable mutation caused the flower of a ginger plant to smell like a processed dung ball (and no…I do not know what that smells like). As this heritable mutation was transferred to future plants over and over again it eventually led to this species of ginger plant which has flowers which attract the dung beetle.
There is another plant which dupes the dung beetle. This grass drops its seeds which look like the droppings of an antelope and even smells of dung produced by an herbivore. The dung beetles believing it is the feces of an animal will roll it up in a ball and bury as food storage and thus dispersing the seed of this plant.
Evolution is the change in the inherited traits of a population from generation to generation. These traits are the expression of genes that are copied and passed on to offspring during reproduction. Mutations in these genes can produce new or altered traits, resulting in heritable differences (genetic variation) between organisms. New traits can also come from transfer of genes between populations, as in migration, or between species, in horizontal gene transfer. Evolution occurs when these heritable differences become more common or rare in a population, either non-randomly through natural selection or randomly through genetic drift. (https://www.sciencedaily.com/terms/evolution.htm)