Hopefully this will help clear things up for you.
First of all, nothing can think itself into a new pattern. I cant will myself or my offspring to have blue eyes.
It happens like this: a snake, like the ancestor of all tricolor kings living today (which need not be tricolor at the time), happen to live in the same range as corals. The corals have a particular color pattern of alternating red/black/white bands, when attacked these red/black/white banded snakes fight back and bite their attackors. Predators learn to avoid these mean red/black/white banded snakes. The predator can eat the ancestor of the kings though, which look different and dont bite. So they eat them, thats not good if you are getting eaten. A mutation comes along in a king snake that gives it some kind of pattern that is similar to the coral snake, it might be very different at first. Maybe just some red mixed in thier pattern. But its enough that predators sometimes avoid it because they confuse it with the coral, and snakes with this mutation live longer and reproduce more offspring than snakes with out this mutation. So after a while there are lots and lots of kings with the mutation, they dont look a whole lot like corals though, so there is room for improvement in the mimicry. But, they do outlast other kings so they have an advantage over them.
Another mutation comes along and makes the pattern even more similar to the coral snake, now snakes carrying mutation2 look more like corals than snakes with mutation1. So now mutation2 snakes leave more offspring than mutation one snakes because mutation2 snakes are prey upon less often than mutation1 snakes. After a while the whole population of kings will look like mutation2 because snakes with that pattern outcompeted snakes with pattern mutation1. They look more like corals now, but not totally so there is room for improvement in the mimicry.
Then mutation3 happens to start the cycle all over again. After many thousands of years of improvement by selection you get a snake that has a patten very very similar to the coral snake. It need not be the same, just close enough that predators are confused for long enough for some snakes to escape and reproduce (more often then those with out the mimic pattern).
hope that helps,
Vinny
-----
“There is a grandeur in this view of life, with its several powers, having been originally breathed into a few forms or into one; and that whilst this planet has gone on cycling according to the fixed laws of gravity, from so simple a beginning endless forms most beautiful and most wonderful have been, and are being, evolved.” -C. Darwin, 1859
Natural Selection Reptiles