How did butterflies evolve to have eyes on their wings?
You're correct with the genetic mutation bit. A basic explanation would be:

Some gene or genes became mutated that lead to the coloration you see, and the end result was that the butterfly or butterflies with the mutated gene were able to produce more offspring or offspring which survived better than the eyeless versions.

There are ways of dating genetic mutations by comparing one organism's genes to another, but accuracy can be an issue without some significant genomic study to confirm mutation rates and other aspects.

However, the butterfly wouldn't be purposefully imitating another creature's eye. It may be by chance and/or predator behaviors that the eyespots look like the eyes of another creature, but the adaptation wasn't a willful act. It was a random genetic mutation or mutations that lead to beneficial coloring, and the eyespots may have improved over time as more mutations occurred.