@The_Idler has it right. Simply a case of convergent evolution, or an old ancestor in common.
Many different creatures share very similar metabolisms, even though they haven’t been related for millennia. Take the simple fact that most multicellular creatures have oxygen-based metabolisms.
On the other hand, it’s possible that they’re totally unrelated, but happened to have evolved to use or create the same substance. This is convergent evolution, and happens quite a lot.
So, the plants you’re referring to probably either have some ancestral link to some similar metabolite that is causing the taste similarity, or have a convergent evolution onto the same or similar metabolite.