How Dogs are Reward and Consequence Based
How smart are dogs? The perception is that dogs have the mental capacity of a three year old human. As a dog trainer, I would agree with this and add that in my opinion, they can even be on the level of a two to five year old child mentally once they are fully developed. Just like it is in a healthy child's nature to explore and test boundaries, a healthy puppy should be doing the same. This is why we love puppies and children so much but it is also why some people and animals prefer not to be in their company.
Many puppies are not respectful of other's personal space. They might know that a person or animal doesn't like the way they are being jumped on, licked, chewed on or mounted, but they get a reward because it is fun for them so they do it anyways. Other times they don't realize that what they are doing isn't good behavior and they are going off of their instincts to play. Dogs are predators so when they are playing one will be the prey and the other dog will be the predator. They go back and forth and one dog will take a submissive position and act like prey in order to get the other dog to go after him. If you pull away and act submissive to a dog when he is trying to play it can make him go after you harder.
While he is very young, the puppy's mother has to socialize him and teach him what is and what is not acceptable. She will protect her other puppies as well as herself from being bullied and harassed. This happens in every single pack animal's pack. There are rules and regulations to living and socializing with others no matter what the species. The is the way the World works and in order to thrive we have to play by the rules.
What happens when a dog never gets properly socialized? It depends on the dog. Some dogs are perfectly fine but others do not play well with others, literally and figuratively speaking. This is how you get unwanted behaviors. Some dogs are not very dominant and if an energetic, aggressive dog is even in the same space, it can make them shut down. Other dogs have all the confidence in the world and would pick a fight with anything breathing if their owner wasn't constantly physically restraining them.
As a dog trainer in Dallas-Fort Worth, I am teaching people how to socialize their dogs. I help them setup up rules and enforce them because having the former without the latter is futile. Rather than re-home, return or otherwise give up your dog because you don't know how to setup rules and enforce them, try to find a good dog trainer in Dallas-Fort Worth who works with difficult dogs and has a good record of success.