It’s experiences, genetics, breeding, and proper training. If all those backgrounds are good generally the dog is. Irresponsible owners are the worst. It’s illegal in most cities to not have their dog on a leash in public. It’s the bad or ignorant dog owners that make dogs bad, except if they have a neurological issue.