The sanctuary is a way to protect your troops from being killed during battle. To change the setting, go to your Castle, click on the overview tab, and look at the radio buttons for "Hide troops in sanctuary".
Hiding troops in santuary will not stop your Wall and Field Defences from defending.
NOTE: When a player from your own alliance has set his troops to hide in santuary, it does not affect reinforced troops, these will defend nonetheless!!