Sometimes it is due to territorial or protective tendencies-the dog is attempting to protect his territory, which could include your premises, your home and yard, and you.
Other dogs are aggressive towards strangers because they are anxious and fearful.