The confrontation at the jail arises when Atticus is guarding Tom Robinson, who is being kept there the night before his trial starts. A mob of men arrive to lynch Tom, but Atticus continues to protect him. Scout is too young to understand what is actually going on; she just thinks that something interesting is going to happen and she wants to see it. That is why she jumps right into the circle of men. She also thinks that these men will be familiar faces, like the crowd who came to see Atticus at home the night before (also in relation to Tom), but she is much mistaken.
Scout simply does not comprehend the seriousness of the situation, as Jem does. Despite the underlying tension, her bewilderment on jumping into a strange crowd of men - and her consequent efforts to make small talk with the only one she does recognise, Mr Cunningham - make for some comedy in this scene. What she accomplishes, quite without meaning to, is the disarming of the mob. Mr Cunningham is put on the spot by her innocent questions and the heat goes out of the confrontation. Cunningham simply decides to leave, and takes the others with him:
Then he straightened up and waved a big paw. “Let’s clear out,” he called. “Let’s get
As they had come, in ones and twos the men shuffled back to their ramshackle cars.
Doors slammed, engines coughed, and they were gone. (chapter 15)
Scout, then, manages to defuse a very dangerous situation. Atticus is both shaken and impressed: 'maybe we need is a police force of children,' he remarks subsequently (chapter 16).