Your dog is still very young, what you describe to me sounds like confidence. You need to just be more assertive in being in control in those situations. That acting out should not be allowed. I train my dogs to ignore people and other dogs. People can come up and talk to me and my dogs will stay in a sit or down which ever command I give them to cap there behavior and let them know to wait for another command or to get a reward. I do not let strangers touch or pet my dog. If they ask I say no, my dog might bite you. That is usually enough of a deterrent. But they are under control at all times. Keep training being in control, let them know you’ve got this snd they will settle in.