DNA doesn’t know anything. It’s purely an information storing molecule that contains information passed on from parent to offspring.
What really happens is that millions of years ago, the praying mantises that looked slightly more like leaves than the other praying mantises were more likely to successfully mate and produce offspring. Of those offspring, those that looked even more like leaves were more successful than all the rest. Slowly, over thousands of generations, the most leaf-like praying mantises were consistently able to survive and reproduce, passing on their genes and, as each generation passed, the praying mantises became more and more leaf like, until the present day.
Latest Answers