Why do some animals try to imitate other animals?
Mimicry, in biology, phenomenon characterized by the superficial resemblance of two or more organisms that are not closely related taxonomically. This resemblance confers an advantage—such as protection from predation—upon one or both organisms through some form of “information flow” that passes between the organisms and the animate agent of selection.

This link describes different types of animal mimicry


  The two step mechanism of mimicry evolution states that,  
  
  1) Mutations at genes of major effect first allow a phenotypic leap
  achieving an approximate resemblance to a particular model.
  
  2) Once these mutations have increased in the population, resemblance can be enhanced through the gradual selection of epistatic
  modifiers.


Considering the case of butterflies, the working of two step mechanism evolved through different types of natural selection process. Experiments show that birds associate certain patterns in the butterfly wings to identify the specie and generalize those features, but a small deviation from the exact pattern is neglected. The increased resemblance is advantageous to species having imperfect mimics. So the species which displays/perform imperfect mimics can some how fall under the list of rejection and manages to survive, thereby passing genes to next generation.


  "Largesse of the Genome", an idea put forward by J.R.G.Turner states that, it is believed that the modification of a trait can be achieved by so many different genes that some of them will inevitably happen to be linked.Amoung the many possible combinations of the loci, selection could simply sieve out the ones that involve linked genes.
  
  Encyclopedia of Insects by Vincent H. Resh, Ring T. Cardé




Although the exact mechanisms of mimicry is still a questionable area, experiments are giving hopes regarding the two step mechanism and more over natural selection is the predominant factor which makes a mimicry successful.

This link describes insect mimicry and two step mechanism in detail.


  References
  
  A Dictionary of Birds 
  
  Encyclopedia of Evolution
  
  Rapidly Evolving Genes and Genetic Systems