Schools provide a common time and space for children of approximately the same ages to come together and learn. And while states have standards for math, language arts, science, and social studies that teachers directly instruct their students in, there are also other skills that students are learning, both directly and indirectly.
Sometimes schools create intentional programs to accomplish some of the goals of socialization. They may focus on a specific character trait, such as honesty or respect, for a month, and intentionally recognize those students who display that trait. And sometimes skills of socialization are taught more indirectly. By participating in class and seeing the behaviors (and rewards and consequences of those behaviors) of classmates, students begin to assimilate into patterns of social behavior that reflect that school's values. So, for example, after watching a classmate have her recess taken away for calling math "stupid," other children learn that this type of language and behavior are not appropriate and should not be imitated.
Depending on where children live, they may not have contact with any other children outside of school (particularly in very rural areas) or may only have contact with children of a race and socioeconomic status similar to their own, determined by housing affordability options. Schools, however, bring together a typically diverse group of students from a variety of backgrounds and ask them to accomplish learning goals together. Students learn to deal with conflict that inevitably arises from being in close proximity to others with dissimilar backgrounds. They hopefully learn empathy as it is modeled through literature and contextual situations. And they learn about healthy competition between students of various backgrounds. Students share recess, lunch, and creative arts classes with classmates who are different genders, races, and abilities and have daily opportunities to engage in healthy and authentic conversations as they discover areas of common interests.
Bullying can have multiple effects on socialization. If it is recognized and handled well at school, other students will see the negative results of that type of behavior and will not be encouraged to follow in that path. It can also indirectly strengthen other friendships as students bond together in resistance of a bully's threats. But if the bully's behavior isn't recognized or if the behavior isn't appropriately dealt with, impacted students will feel unsafe at school and will likely retreat socially in an effort to disappear from the bully's radar.