Only troops donated to you by your Clan mates can defend your village against attack. You first need to create or join a clan, and then request troops, i.e. ask that other members in your clan donate troops to your Clan Castle. You can then use those donated troops for your own attack, or they will automatically deploy in case your village gets raided an enemy units enter the Clan Castle "trigger zone".
It's worth noting though that units will only come out of the Clan Castle if the village is under attack by units they are able to attack. For example, Balloons will not come to the defense from the Clan Castle if the village is attacked by air units. This is because Balloons can only attack ground units.
If any units repel the attack and survive the siege, they will return to the Clan Castle as only units that have perished disappear. Surviving units will also regain full health.