What is Müllerian mimicry?
Proposed by Fritz Müller, is when two or more species, which are both unpleasant to eat, poisonous, toxic, harmful etc. have similar colouration and patterns. A key point to note is that they have common (shared) predators. A classic example is the Heliconius genus of butterfly.
Why does it evolve?
The argument you make is kind of along the right lines, but it is a group selection argument, and is worded slightly badly as it insinuates that evolution is a goal driven process. I will use a toy example/thought experiment to explain why it's evolution is adaptive.
In this example there are three species of butterfly are toxic. We will call these species Butterfly-1, Butterfly-2, and Butterfly-3 (yeah, I'm not feeling very creative today). We also have a predator, a bird which likes to eat butterflies. We will call this species Bird.
Butterfly-1 and Butterfly-2 are very different to look at; they have different colours, shapes, and patterns. An individual Bird then eats one of Butterfly-1 and becomes sick. That individual learns to avoid Butterfly-1. Our Bird is then hungry again, and eats Butterfly-2, and again gets sick, and learns to avoid Butterfly-2. Two individuals die before Bird can learn to avoid both species.
Butterfly-1 and Butterfly-3 are very similar in appearance; they have similar colours, shapes, and patterns. An individual Bird then eats one of Butterfly-1 and becomes sick. That individual learns to avoid Butterfly-1, but also to avoid the similar looking species Butterfly-3. Likewise, if it eats a Butterfly-3 then it learns to avoid both Butterfly-1 and Butterfly-3. This is Müllerian mimicry. Survival is higher in one or both species because of more rapid learning by predators, fewer individuals will die compared to the non-mimicry scenario.
The essence of this is captured in the following statement from this paper:
"Müller provided what could well be the first formal mathematical model to support an evolutionary hypothesis. Following Müller’s original argument (1879), let $a_1$ and $a_2$ be the numbers of two approximately equally unpalatable (or otherwise defended) species in some definite district during one summer, and let $n$ be the number of individuals of each distinct unpalatable species that are killed by predators during a season before their distastefulness is generally known. If the species are distinct in appearance, then each species would lose $n$ individuals in the course of educating predators. If, however, the two species were exactly alike in appearance, then the first species would lose only $a_1n/(a_1+a_2)$ and the second would lose only $a_2n/(a_1+a_2)$. Under these conditions, a mimetic mutant of species 1 that perfectly resembled species 2 would tend to spread from extreme rarity"
- Note that there may be caveats and complexities which I haven't discussed, this is a simplification to try and explain the general reasoning