Answer:
Samurai were employed by feudal lords (daimyo) to defend their territories against rivals, to fight enemies identified by the government, and battle with hostile tribes and bandits. For this reason, samurai could live in barracks, in a castle or in their own private homes.