system
Given the following post, respond as if you're commenting on Reddit:
human
How does toxicity evolve in animals?

Ive asked this question somewhere else before but only got lackluster responses with the catch all answers 'evolution the end', figured experts might have better answers. 

The question is this, how does being toxic to eat evolve in species? Say you are a frog and thanks to a random mutation your flesh is now toxic to eat (even though this would likely be more incremental over genetations?) It seems to not be terribly beneficial to have this trait if it only does something once you've been eaten. I understand how its helpful once the trait is established and predators know your not good eating, but all traits have to start somewhere and I'm curious as to how something only posthumously beneficial gets passed on as beneficial.

Addendum: Why don't we see more animals (i.e. mammals) with this kind of adaptation if its generally helpful not to be eaten.
gpt
Toxicity, like all adaptations, evolves through small modifications on an existing template, selected for because it increases fitness.

Your sticking point seems to be in understanding how something not directly beneficial to your own survival can be selected for.  That's a great question.  

The answer is that you don't need to ensure your own survival for natural selection to act.  You need to ensure the survival and propagation of your *genes*.

So, if you sacrifice yourself and kill a predator before it can eat your babies, well done!  If the predator - after having had several members die after eating your species and not having a chance to reproduce - evolves to no longer eat species that look like yours...even better!