'Those who fail to learn from history are doomed to repeat it' is a maxim that makes sense on one level and turns up in a lot of fiction, the character determined to fix past mistakes only to end up repeating them in an ironic twist. Thing is did that character fail to learn from history or did they just learn from the wrong version?
This isn't based on the idea that history is written by the winners, in fact I would say that the losers have often gotten better writes up than the winners, consider Napoleon or Robert E Lee. What I'm talking about here is the chasm that often exists between the common knowledge or pop culture version of historical events and the facts of what actually happened. The Battle of Dunkirk offers a great example of this. At the height of the battle Hitler issued what has become infamous as the 'Halt Order', which suspended attacks by the German army on Dunkirk for three days, allowed the British to consolidate their defence perimeter and carry out the evacuation. There are actually two 'common knowledge' versions of why this happened. The first is basically that Hitler was a lunatic, he panicked about a minor counterattack and called the halt over the vehement objections of his generals. The second explanation is that it was because Hitler admired the British Empire and let the troops escape in the hopes of getting the British to 'see sense' and make peace.
So which version is closer to the truth? Well neither actually. The description I gave of events surrounding the Halt Order is certainly the one that most people who've heard of it would give, but reality is something else. The fact was that only the Panzer divisions halted, the rest of the German forces maintained their pressure on the perimeter. More than that, it was the frontline generals who asked for the halt. They needed to regroup after two weeks of non stop action and they wanted to save their tanks for the operation that was going to bring them fame and glory, crushing the French army and driving into Paris.
Does it matter that the general public has the wrong view of events? I would say yes, as it often downplays the contribution of those who made huge sacrifices to influence events. From a writing perspective I would say it matters even more. If you buy into the notion that 'crazy people do crazy/stupid things because their crazy' it encourages last writing. Most of the 'stupid' decisions you can point to in real history have a rationale behind them that made sense to the characters at the time, that rationale may be misguided, or yes plain insane, with hindsight but based on what the character knew or believed it made sense.
In short characters may do stupid things for stupid reasons, but there is always a reason that makes sense to them.