Good answer Andy. Of course, "animals" includes more than cats and dogs...
Some animals are very territorial, defending a boundary line from others. Some only defend a core area of a territory. Others still just have a home range where they live, but do not try to keep other out. Others just wander. Animals may do different things at different times of year. Territories are usually only defended against the same species, but sometimes also against other competitor species (bears and wolves, for example).
Territories generally give the animal (or group) exclusive use of some limited resource, usually food or mates.