What evolutionary advantages does a longer muzzle have against a shorter muzzle and vice versa
Its mostly due to different forms of predation. 

Longer jaws are deeper and can reach farther around a prey item, it also increases the chances of catching a moving target in the jaws becasue the area the jaw covers is larger, all things being equal it should always be favored but things are rarely equal, everything has a cost. It is common to see longer snouts in animals that hunt primarily with the jaws. There two ways to do this which depends on how big the pery to are after is, for predators going after relatively small prey they favor long thin snouts, is really noticable in aquatic predators like gharials, it makes for a very fast bite with a wide attack range. Alternatively if they are going after large prey they need to balance strength with speed so you see long, but not as long, more robust snouts. Think alligators, hyena, wolves. Whereas cats who attack with their forepaws can use a smaller head and jaw and favor a more precise bite, becasue they are moving with the prey becasue they have grabbed it, the arms are absorbing most of the stresses. Cats favor grabbing and strangulation for which a small short jaws works fine. Energy and material saved here can be used elsewhere. A longer snout would be weaker unless they add a lot more muscle to stabilize it. In terms of resources it is a lot of cost for little gain, whereas in wolves it is worth the cost becasue they need that strength anyway, becasue they jaw is where all the stress of the struggling prey is being transmitted. 

You see the same thing in dinosaurs, predators that can attack with the claws have weaker bites/smaller heads. In the case of dinosaurs however snout length varies less because the small heads favor slashing bites, which favors a longer snout (thus a longer cutting row of teeth) there heads get narrower and weaker more than shorter.  Mammals can't use this strategy because they don't get replacement teeth, and they would quickly not have a tooth in their head, so instead you see strangulation favored instead.

Of course an animal can try to balance a range of strategies and there are all kinds of specialized forms like saber teeth, venoms, ect. Of course this is also simplified a lot of other things effect snout length as well, things like climate (long snouts cause less heat/water loss through breathing), sense of smell, or even vision.  

https://www.cambridge.org/core/journals/paleobiology/article/dinosaurian-and-mammalian-predators-compared/BE3492DA7E0A103C6F6E77B9611D86A9

https://link.springer.com/chapter/10.1007/978-1-4615-0161-9_14

https://www.cambridge.org/core/journals/paleobiology/article/constraint-and-adaptation-in-the-evolution-of-carnivoran-skull-shape/77B1591461066F9D0E30F309F6C495C6

https://www.sciencedirect.com/science/article/pii/0034568770900757