It’s not that complex.
A mutation happens. It can result in either a disadvantage that prevents the plant from surviving to reproduce or an advantage that helps the plant survive to reproduce.
There’s no “knowing” involved. There is no intent on the part of the plant. It’s just random. You’re seeing the descendants of the plants that got an advantageous mutation.
What you’re not seeing in your yard are the billions of different plants that never survived because their mutation was a disadvantage.
It’s more than that, but some of them accidentally believe that democracy is good.