How did we get from wolves to dogs of all sizes? How do pugs and chihuahuas and pit bulls and English bulldogs and German shepherds and so forth all come from the big Grey Wolf? Evolution! We domesticated wolves by adopting cubs and feeding them and slowly changing their habits. Over generations, the wolves changed and created a new species which we humans selectively bred (over-bred, probably) to exaggerate certain traits to perform certain tasks.
Dog breeds have gotten so different that they have three types of skulls. A dolichocephalic skull, which is common in dogs bred to hunt and sniff, a mesocephalic skull, that’s the most common and a brachycephalic skull, the flat one.