As much as I would like it, both in Worldbuilding and Writing, not every action is logical or "right".
There are two types of this:
Imperfect information: The character(s) lack vital information, making their choices a gamble.
Characters being plain stupid: The classic case when you look back and ask: "What was I thinking?"
Sometimes there's nothing wrong with charaters being stupid, other times it turns out terribly, for example, I hated that scene from Babel where 2 characters were shooting with a hunting rifle at vehicles to see if its range really is 3 kilometers. It felt absolutely disgraceful, dumb, disgusting and upsetting, yet some could argue that they really didn't know what they were doing.
That leaves us the question: How do I have intelligent or normal characters have moments of stupidity, that might or might not drive the plot forward, without feeling like they were possessed by the writer or just breaking character in general?