Let me point out that the dangerous situations in the two stories are of different natures and may not even seem particularly dangerous, not in comparison to a spy story, for example.
The dangerous situation in "After Twenty Years" is that Patrolman Welles is approaching an unknown person standing in a darkened doorway of a business neighborhood that closes early with all the shops quiet and secure.
The dangerous situation in "The Lottery" is that villagers are standing in clusters--with the children having to be called away from a great pile of stones--awaiting the conclusion of the lottery drawing.
The character's behavior, in the first, is that Patrolman Wells "suddenly slowed his walk" at the sight of a seemingly unexpected man leaning in the darkened door of a hardware store--retrospect tells us he slowed in his tracks from the emotion of fulfilled expectation. When Wells perceives the truth of his situation through the service of a lighted match when "[the] man in the doorway struck a match and lit his cigar" (as in Narayan's "The Astrologer's Day"), he remains calm, gets additional information, then moves calmly away, quietly continuing his duties.
The policeman twirled his club and took a step or two.
"I'll be on my way. Hope your friend comes around all right. Going to call time on him sharp?"
"I should say not!" said the other. "I'll give him half an hour at least. If Jimmy is alive on earth he'll be here by that time. So long, officer."
In the second, villagers complain about how long the process takes. They talk about their perception of an ever-shortening time between annual lottery drawings. While standing passively, they watch who goes up and are intent on the proceedings though in a distracted, anxious sort of way.
"I wish they'd hurry," Mrs. Dunbar said to her older son. "I wish they'd hurry."
"They're almost through," her son said.
O. Henry uses the Patrolman's motions and psychological state of outward composer despite inner anticipation to paint a picture of a dangerous situation, emphasizing the behavior of the one who poses the danger (Silky Bob). Jackson uses the villager's collectively uniform distraction and anxiety to paint a dangerous situation, emphasizing the behavior of the ones to whom the danger is a threat (the villagers).
Silky Bob in the story "After Twenty Years" is a man who returns to his hometown to meet a friend. He chats with a policeman while waiting for his friend to arrive. Silky Bob believes that he is above the law. He has gotten away with illegal activities for a long time and prospered from them. He is so confident that he does not mind chatting with the policeman. He is even so bold that he strikes a match which lights up his face allowing it to be seen by the policeman.
Tessie is excited about the lottery until her name is narrowed down to family members. When she realizes that there is a possibly that she might be picked she panics. In her panic she desperately tries to add other relatives to her household's list. She suddenly fears that she will be chosen and put to death. She is right and is soon chosen and is stoned to death.
The main difference that I see in the two is the way that each one perceives danger. Initially Tessie sees no danger, but when it becomes real she becomes assertive and panicked. Silky Bob never recognizes that he is in danger of being caught until the end when he is set up by his old friend who is the policeman.