Ancient people engaged in a sort of arms race with war animals. An army on horseback was better than an army on foot, and then armies started showing up with camels or war elephants, both of which trumped horses, which, if they had never seen such creatures, fled from them in terror.
The horse, despite its great size, differs from the dog in that it is a prey animal rather than a predator, and it lives by the philosophy, “If in doubt, run away.” Thus when confronted with something that looks and smells unfamiliar, it’s going to forget its training and bolt.
War elephants were particularly problematic, and commanders whose armies faced them had to find a way to deal with them. Alexander the Great, campaigning in India, learned that elephants were repelled by pigs–especially by the high-pitched sound of their squealing. He used pigs successfully to drive back war elephants in 326 BC, and the Romans used the technique again in 280-275 BC.
In 270 BC, Megarians broke a siege on their city by smearing pigs with pitch, setting them on fire, and releasing them towards the line of besieging war elephants. The elephants, terrified of the flaming pigs, fled in all directions, and Megara was saved.