Rather than continuing to fear, the Nephites (including Lamanites turned Nephites) called Gidgiddoni as their chief captain, "someone that had the spirit of revelation and also prophecy" (3 Nephi 3:19). Because the Nephites had repented and were strong in the gospel, they recognized it was important to be led by a righteous man who called upon God for strength and guidance. They had faith that God would lead this righteous man and, as a result, them.

Some of the people asked Gidgiddoni to pray unto the Lord to protect as they rashly went up into the mountain to fight against the Gadianton robbers. Understanding that at this point, they would die if they went to fight against the Gadianton robbers, he said that they needed to prepare themselves first. And they did. They listened to Gidgiddoni as he told them to all gather in the center of the land with their flocks and all of their sustenance. They fortified and strengthened themselves physically and spiritually (through repentance, faith, and prayer).
I do not think it was easy for them to do this. I'm sure it was not easy to move everyone to one place and to leave your homes, not knowing if you would ever return. But, the people had faith and it won them the war. Because they had the Lord on their side, they won the war against the Gadianton robbers and were able to erase them entirely from their lands and people (for a time).
Moral of the story: It is not always easy to obey Heavenly Father and his commands. Sometimes we don't even know why we're told to do something (just like the Nephites), but we know that we should do it. If we have faith and prepare ourselves in every way possible, Heavenly Father will use our obedience to open doors for us. He will teach us lessons, He will help our faith to grow beyond what we thought we were capable of.