In Deuteronomy 13:12–18, the Law of Moses specified what Alma needed to do if there were an apostate city in the land:
If thou shalt hear say in one of thy cities, which the Lord thy God hath given thee to dwell there, saying, Certain men, the children of Belial, are gone out from among you, and have withdrawn the inhabitants of their city, saying, Let us go and serve other gods, which ye have not known;
Then shalt thou inquire, and make search, and ask diligently; and, behold, if it be truth, and the thing certain, that such abomination is wrought among you; Thou shalt surely smite the inhabitants of that city with the edge of the sword, destroying it utterly, and all that is therein, and the cattle thereof, with the edge of the sword.
And thou shalt gather all the spoil of it into the midst of the street thereof, and shalt burn with fire the city, and all the spoil thereof every whit, for the Lord thy God: and it shall be an heap forever; it shall not be built again.
Alma was the Nephite high priest, and had the personal responsibility for seeing that no iniquity defiled the land. Under this law of the apostate city, if there was wickedness in a city, he was required to warn the inhabitants. If they did not repent, he would consign it to being killed by the sword and having it burned and completely destroyed. The legal requirement said that he must inquire diligently. It could not be a superficial observation. He could not destroy a whole apostate city without a very thorough investigation, but "if in truth abomination is wrought among you" then it says you shall "smite the city with the edge of the sword, destroying it utterly."
The words utter destruction—in Hebrew—form a phrase that is quite distinctive, and it means being wiped off the face of the land. How many times does Alma use this phrase utter destruction in chapter 9? Three times, in verses 12, 18, and 24. We do not know if the people in Ammonihah knew the scriptures well enough to understand what Alma was saying and what was happening here, but apparently they did, because their reaction was so extreme. Alma gave them not only practical and religious encouragement, but also legal notice and fair warning that if they did not change and repent, their destruction would be made sure and complete. Amulek would next go on, as the second witness, to tell them that they would "be smitten by famine, and by pestilence, and by the sword" (10:23).
It must be said that Alma, of course, no longer commanded the army, and would not have been inclined in any event to call in the soldiers to obliterate the city. This destruction mandate in Deuteronomy 13 was a part of the Israelites’ conquest of Canaan, and there are many Jewish law scholars who maintain that it was a unique command, applying only at that time when the Israelites took over Canaan and had to establish themselves, and even then, only after they had offered a peaceful settlement and arrangement with cities that were problematic. So, Alma may not have thought that destroying the city would happen in this case literally and under Nephite command. In what seems to be an act of providential justice, a Lamanite attack happened to come and all this destruction happened in one single day—a "coincidence" that Alma and all Nephite record keepers would have found quite remarkable and compelling as a sign of divine intervention and prophetic fulfillment.
John W. Welch, "The Destruction of Ammonihah and the Law of Apostate Cities," in Reexploring the Book of Mormon: A Decade of New Research, ed. John W. Welch (Provo and Salt Lake City, UT: FARMS and Deseret Book, 1992), 176–179.