In our case our parents teach us
Not 100%. There are certain tastes and smells that are hardwired in us to cause revulsion. Many of these are the things that you would expect. Meat that has gone off, excessively bitter plants, stagnant water etc. There are some things that a completely unparented child would not eat.
Fungi are a weird one, though. I used to know a tiny bit about this, but I can’t remember it now. But the toxins that exist in a Deathcap, for instance, are not evolved from a need for defence. So they do not revolt in the same way as a plant toxin that is evolved to defend the plant against a grazer. That is why fungal toxins are so dangerous in many cases as they don’t stop you in your tracks.
On the other hand, a plant toxin evolved for defence isn’t much good to the plant if it kills you 24 hours later when you’ve already eaten the whole thing.
There are plenty of plant toxins that aren’t evolved for defence too, mind.
When I was a kid on cub camp I saw a Deathcap in the woods (I was always interested in toxic plants etc so knew what it was). However, I touched it and then realised I didn’t know much about the lethal dose, whether it secreted it etc. I must have washed my hands at least ten times as a result!