Evolution doesn't plan ahead. Various plants got various random mutations that produce various random chemicals. The ones that were tasty to birds but disgusting to mammals for their seeds spread all over and ended up pretty widespread, so they survived and became common.
The ones that were repulsive to birds but tasty to mammals got eaten by something that grinds up their seed, and so they are extinct. Or, (after humans invented agriculture), possibly got domesticated and became extremely numerous since we'd intentionally save some seeds to plant despite eating the rest.
But there was no awareness and no plan, just chance and history and whatever happened to work.