In The Kite Runner, why did Khaled Hosseini have Amir Sohrab and Assef come together the way they did in their encounter?
You originally posed this question asking why these characters came together "in the same way," which is a bit unclear. I am basing my response on the understanding that you are asking why this encounter toward the end of the book parallels in some ways the encounters of Amir, Hassan, and Assef earlier in the novel.
This is a novel about wrongdoing and redemption. Hosseini has created a character, Amir, who makes regrettable choices and another character, Hassan, who shows Amir how people should behave. Hassan is a true friend to Amir, saving both of them from Assef and his friends with a slingshot. Amir cowardly fails to save Hassan from Assef raping him. He says,
I had one last chance to make a decision. . . I could stand up for Hassan—the way he'd stood up for me all those times in the past. . . In the end, I ran. I ran because I was a coward (Hosseini 77).
While this is not Amir's only wrongdoing toward his friend, it is the most striking and significant, setting the stage for the banishment of Hassan and his father Ali from Baba's household, which results in Hassan and Ali being left behind to die after Baba and Amir flee to America.
When Amir is offered a chance "to be good again" (2) and returns to Afghanistan to save Hassan's son, Sohrab, he is on his way to redemption in a scene that is a kind of combined reenactment of the two crucial encounters with Assef, the first being the slingshot encounter, the second being the rape of Hassan. In this encounter, Sohrab is a kind of "stand-in" for Hassan, who is dead, but whose son is still alive. Amir rescues Sohrab from the evil Assef, who clearly has been molesting Sohrab since he took him. Sohrab rescues Amir by slaying Assef with a slingshot, just as his father did before him. This is almost like a do-over for Amir, a way for him to be make the choice to be brave and rescue Sohrab. Khaled Hosseini creates a kind of symmetry to the book by setting up this situation to contrast Amir the immature, cowardly child with the mature, brave man he becomes.