What we need to look at is how these frequencies change. There are several processes that increase the genetic variability of a population. Mutations increase variability. This is not always good change, as you've seen before. The point is, however, that the frequency of the alleles increases when there are mutations.
Recombination also increases variability.
Recombination refers to the processes of reassortment and crossing over. These happen during separation of the chromosomes as gametes are produced by meiosis. Gene flow can increase genetic variability by bringing in alleles from other populations. There are several processes that decrease the genetic variability of a population. Natural selection retains relatively more of those alleles that are favorable and tends to reduce those alleles that are less favorable in a particular environment.