Why do most mammals have long snouts?
Obviously there is an evolutionary advantage for those animals which has a long snout/muzzle. That is why they are still around.

For carnivores the canine is the most important tooth and it is positioned strategically at the front corners of the jaw. Canines are meant to pierce and is essential for holding on to the prey and preventing from escaping. They are also essential for tearing flesh.

Lower jaw or the mandible is a class 3 lever. The lesser mechanical advantage is compensated by the extremely powerful muscles. Since the muscles are closer to the joint or fulcrum the movement produced by the muscles are amplified at the outer end of the jaw allowing for wider opening of the mouth. Since the canines are sharp and long there is enough force to pierce.

Herbivores like cattle and sheep have no canines (horses do have canines). The longer snout/muzzle may help in grazing as it would help in reaching the ground along with longer necks. The longer snout/muzzle means more space for the premolars and molars which can be more in number or larger fro grinding the food.

Crocodiles which are not mammals also have long snouts.

In short the longer snout/muzzle in different animals developed due to evolutionary advantage based mainly on diet.