Why don't my characters operate on defense when village is attacked?

Solution 1:

Troops in your army camps are only for attacking, not defending. If you would like to have troops defend your base, you can repair your clan castle and join a clan. Once you have both a clan castle and a clan, you can request troops from your clan to defend your base. These troops will continue to defend your base until they are killed by an attacker, or you use them for attacking.