@Mame,
My Border Collie, Brady, (see avatar) barks when he hears the other strange dogs barking outside of my aprtment but he doesn't bark outside when they bark. So I can tell you with some certainty that this is about a challenge of territory with strange dogs. Outside my dog doesn't feel any challenge as he knows outside is NOT his territory. Inside at our place he's announcing to the other barking dog that this is his territory.
There is some dynamic to this as to what your own dog considers his/her Alpha status in question..or just some plain excitement. I'd keep a treat in my pocket..and say 'no bark' firmly to see if you can influence him/her to stop.
While at the park, he doesn't bark. He's notoriously (and peculiarly) skittish but runs and fetches a ball like the wind. He doesn't bark at the other dogs. In fact, he totally ignores them due to some oddity in his upbringing (rescue) before I got him. Because of his peculiar personality, he focuses intensely on fetching but will not challenge another dog. he will race them to the ball but if they get the ball, he will let them and the ball alone. Then I have to get the ball from the other dog. But if he wins the race, he runs the ball back to me with not one single bark. Go figure. He's a pacifist and so peculiar that way. There's never a dog fight.
Many Border Collies seem to express their territorial dynamics differently than does my dog. I knew 4 other Border Collies (his former pack) who behaved similarly to
your dog. Once your dog gets more used to things or when you train him with rewards for not barking , perhaps your dog could respond differently and bark less. Sounds like he/she's excited.