When characters fail to use an obvious solution, or forget a skill or superpower that could easily resolve the situation, it can be pretty frustrating for the readers.
It can also hurt their opinion of the characters' intelligence, or of your attention to detail, even if the story is otherwise awesome.
How do you avoid instances of "Why didn't they just"?
Here are a few ways to either keep the readers from asking "Why didn't they just...?" or to use the characters' mistakes and oversights to drive the plot, increase drama, or induce character development:
1. List your characters' abilities, and refer to them when the characters face a crisis.
Whenever your characters are in a difficult situation, and are considering using a painful, dangerous or unethical solution to solve their problem, pause and ask yourself:
"Do any of these characters have a skill, connection or superpower that could resolve this problem in a safer, saner or more moral way?"
If the answer is "Yes", then refer to methods 2-4.
2. Make the problem harder to solve.
If you don't want your characters' current abilities to enable them to solve the problem easily, ask yourself, "What are the holes or weaknesses in these abilities? What extra challenge or obstacle could I throw in, that would neutralize the power they'd normally use to fix this situation?"
This can add some extra character drama, because the ability they normally rely upon is suddenly useless, leaving them out of their element and causing them to either grow and adapt or freeze and fail.
3. Explain how somebody already tried the solution they're considering.
"We tried to warn them. They didn't listen/they were in on it all along/our contact turned out to be a spy."
"I already tried that superpower on it. Turns out, he saw that coming and used X to defend against it."
Alternatively, you can have them try the simple solution on-screen, and maybe even give the characters and audience a glimmer of hope that it's going to work... before dashing their hopes and forcing the characters to think on their feet.
4. Point out the fact that a better solution was ignored.
If a character isn't very bright, was too stressed to think clearly, or has a flaw in their personality that causes them to jump to extremes or ignore simple solutions, this can turn a moment of "Why didn't they just...?" into an opportunity for drama and character growth.
A character who shot an enemy needlessly can realize that they're too quick to violence, while a character who failed to shoot a villain and let innocent people die can realize that they're prioritizing keeping their hands clean over other people's lives.
A smart person who missed a simple solution while seeking a complex answer can discover the flaw in their thought process, and a person who failed an important mission due to an obvious mistake can go through a serious emotional crisis as a result.
Avoiding "Why didn't they just...?" can be a lot of work, but it vastly improves your story.
On top of not annoying or frustrating your readers, taking the time to explore and account for all possibilities can greatly improve your story in other ways.
It can make the characters seem smarter, because they've taken so many factors into account while making their plans.
It can drive character development when they realize that they've screwed up.
And it can add new plot threads in which your characters attempt the solutions you came up with, only to fail. I recently had a situation like that in one of my works in progress; I had a tragic and poignant scenario I wanted to write, but for the character to be driven to such terrible extremes, EVERY other possibility had to be eliminated.
It forced me to do a lot of thinking, and in the process of eliminating the other possibilities, I actually ended up fleshing out the character's personality, backstory and family history far more than I would have otherwise.
I also made great improvements to the antagonist, because I really had to explore his personality and abilities in order to make him dangerous enough to justify the protagonist's desperate measures.
It was a lot of extra work, but the outline is already far better for it, and I know the finished story will be, too.