Why do Jem and Scout refuse to obey Atticus' command to leave him alone in front of the jail?
Jem and Scout each have their different reasons for refusing to leave Atticus alone. Jem seems to want to protect his father, while Scout simply does not realize the gravity of the situation. In her innocence, she does not realize that the mob in front of the jail is there to hurt her father.
Jem likely knows that his being there can be dangerous, but he wants to be brave and protect his father. Scout does not know how much danger she is putting herself, and possibly the rest of the group, in so much danger by being there because she only sees good in people. It does not occur to her that anyone might actually do her or her father harm. This innocence and naivety allow her to step out into view (they had been hiding before) when she recognizes Walter Cunningham's father. She tries to have a conversation with him, seeminly unaware that the men are there to hurt her father. Her innocence helps to restore the sense of humanity in Mr. Cunningham, and he asks the crowd to leave.
Though Atticus is undoubtedly upset that his children stayed rather than obey his orders, he cannot help but be thankful that their presence deterred any violence from occuring. As they walk away, he ruffles Jem's hair as a small thank you for being so brave.