It helps that dogs have 39 pairs of chromosomes, which is more than most other mammals (humans have only 23). So it's relatively easy to selectively breed for certain desirable phenotypes without getting too many undesirable ones. Although the process isn't perfect so we still see a lot of inbreeding and genetic diseases in some purebreds.