[Dd] [Tt] Surface: There are two surface genes - Dirt and Turf. Foundation horses (horses with unknown parents) always have at least one green (XX) surface gene. However, it is entirely possible to get horses with semi-dual preferences (XX Xx) or even fully dual (XX XX) preferences.
These genes determine how easily your horse trains on each surface. Horses with Xx or xx genes can still run as well on a surface as a horse with XX so long as they are trained properly.
[Sp Sp] [St St] Distance: There are two pairs of distance genes - Speed and Stamina. These determine how much speed and endurance your horse has, which determines what distance they like to race. Horses who tend to have shorter bursts of speed and less endurance will have stronger sprint genes and horses who have less speed but more endurance will have route genes.
A horse's stats (such as Early Speed or Late Speed) do NOT determine what distance they race. A horse who has a high Early Speed stat may still be a very good router. These genes are simply evaluating a horse's capabilities to define an ideal distance range. Stats look at their abilities when racing at the appropriate distance. Horses who have a mixture of speed and stamina genes will end up preferring something in the middle, making them Milers.
If you want to breed Sprinters or Routers, your best bet is to cross horses who have similar genes, otherwise you will end up with a barn full of Milers.
Milers are undesirable because they may only be able to train for 1-2 distances, will gain distance familiarity slower, and will often have lower stats than a horse than a horse who is Excellent+ for either Speed or Stamina.