Different groups of pre-historic humans may have captured different types of wolf or other canid pups and raised them to help them hunt. Selective breeding led to different breeds within a few generations. Then commerce and travel led to these breeds mingling both with other domestic breeds and possibly the non-domesticated canids in the region. Amazingly, too, dog-breeding has led to animals perfectly suited to their original purposes. Rottweilers and German Shepherds are alert and bark a lot, making them excellent watchdogs.
Pointers silently lead their masters to hiding game and freeze in a pointing stance.
Retrievers like water all the better to jump in and bring back fallen birds for their hunting masters. Terriers, meanwhile, are brave enough to chase rodents into holes, and have a wiry coat to protect against their victims bites. The warm-coated Samoyeds and Siberian Huskies were bred to haul sleds, while Newfoundlands and Saint Bernards are big and strong for hauling loads. Pomeranians and Maltese were bred to be friendly companions. Looking at these different breeds, one can see that we humans have, indeed, developed the perfect dogs for each task.