Dogs like to mark their territory. They also leave a smell behind so that the other dogs can recognise the friendly ones. They can also determine whether they have entered others’ territories or not to avoid danger.