With territorial aggression it's usually the opposite. Agression is on, what the dog considers, his "territory" - that is usually defined as the property that the dog is kept on. So the fact that he is getting defensive when outside, leads me to believe that it's just fear based aggression. Hackles up indicate sharpness, the dog is getting defensive around unfamilar stimuli in his environment that he percieves as threatening. The dog has to feel genuinely threatened for this to happen.
So the first step is understanding that your dogs response is fear based. Then it's up to you to decide how you want to deal with it. I ge tthe impression that you want to eliminate this behaviour. If so, you need to work on desensitizing your dog to the things that he is having a reaction to. Learn to engage with your dog and do this at distances that don't elicit the wrong response from your dog, then gradually increase the distance. Praise and reqard him for engaging with YOU in the presence of distractions BUT don't set your dog up for failure by approaching to close.
Dog aggression can often be a problem with male dogs. Sometimes all you can do is keep it at a level that is managaeble.
All dogs have protective instincts, but it's unrealistic to expect the to conform to our expectations of what "we want" from our dog