All abilities are assigned a number - 1 & 2. A Pokemon with ability 1 will evolve to a Pokemon with ability 1, while ability 2 Pokemon evolve into ability 2 Pokemon. Let's use Poochyena as an example.
Poochyena has 2 abilities - Run Away and Quick Feet. Mightyena also has 2 abilities - Intimidate and Quick Feet. Run Away is #1, while Quick Feet is #2. Mightyena that have Intimdate evolve from Run Away Mightyena while Quick Feet ones evolve from Quick Feet Poochyena.
If 1 ability Pokemon evolves into a Pokemon with 2, then it is a 50% chance of becoming either, based on personality value.
Source