The most easiest way of protecting your army and your Castle is to use the Protection Shield. If you have the Protection Shield enabled, you will be protected from enemy's attack and scouting.
The Protection Shield will protect all the army inside the Castle. But your soldiers collecting resource on the field as well as in the Assembly are not protected by the shield.
If you don't have a shield and an attack is coming, you can send your army to a nearby resource tile. But be careful. The resource tile may also be attacked. You can also protect your army by sending your army to a nearby Alliance member's Castle or use teleport item and relocate your Castle.
If you go nearby your Alliance members by using the Alliance Teleport or Rookie Teleport item, you can reduce the number of attacks you receive.
Build Hospitals and upgrade the building to heal the injured soldiers.