Pink Floyd created concept albums that were, for the most part, produced collaboratively. After the departure of Syd Barrett, Roger Waters usually took the conceptual lead, but the other musicians contributed significantly to the finished products.
While this remained partially true for The Wall, the responsibility for the songwriting was less balanced and leaned more toward Waters than the other members. One indicator of this is the album's writing credits—all songs are attributed to Waters except the four in which he shares credit.
The concept behind the album emerged during the band's In the Flesh tour. Water's confrontation with an unruly fan led him to reflect on the sorts of things that had alienated him from his audience, and which isolated him and others more generally from society. Waters developed a broad storyline for the entire album, pitched the idea to the rest of the band, and then worked with recently recruited producer Bob Ezrin to develop the concept further.
This led to the construction of a fifty-page album script that was less narrowly autobiographical than Waters' original story. While Waters' own experience would continue to inform the story—the death of his father, his overprotective mother, his schooling, etc.—the story that would become the album was more broadly framed. Once complete, the script was read by the band as though they were rehearsing a play.
Waters received sole writing credit for "Another Brick in the Wall, Part 2" and it's one of the songs inspired by his own experience. But producer Bob Ezrin had played a large part in constructing the song. He was responsible for the uncharacteristic disco beat, and he had turned a one-minute track into a three-minute single without the assistance and, initially, the support of the band.