Natural selection works by imposing different rates of success on genetically diverse organisms. Given a certain amount of hereditary variation amongst members of a population, some individuals naturally thrive, while others die young or fail to breed.
Every living thing faces a set of challenges in the world. Organisms must eat without being eaten, resist disease and parasites and eventually reproduce. The way an organism approaches these challenges is conditioned by its genes, which build organisms' bodies and influence their behavior. Some life strategies work better than others, such as running from predators rather than standing and fighting, so the individuals with the stronger flee genes tend to live longer and have more offspring. Those offspring are statistically more likely than average to have inherited the flee genes from their surviving parents. In this case, selection has worked to select for flee genes and against fight genes.
Given enough time, and many successive trials over thousands of generations, flee genes may come to dominate the population until every member of the gene pool has them. In this case, natural selection shaped the gene pool in such a way as to make flee genes a feature of the species that helps it thrive in a predator-rich environment at the expense of fight genes.