Many people learn from their experiences. We learn from the good choices we make, but more often, the most important lessons we learn come from our mistakes. Of course, it is possible to learn from other people's mistakes, which is why it's important for fictional characters to make mistakes.
Personally, I don't like making my characters mess up. But that makes for a boring story. One of the easiest ways that I know of to get my characters into trouble is for me to look at the mistakes that I've made. Recently, I got pulled over for something really minor, something the officer probably shouldn't have even bothered with, but since I was doing something I shouldn't have, I'll take responsibility for it. However, I started thinking, how would my protagonists handle this situation?
One of them might act similarly to how I'm going to, but the one I'm working on right now? He would probably mouth off to the officer, maybe even aggravate the man enough to get himself arrested. His car would be impounded, and the police would find an assault rifle in his trunk. And that's a consequence I don't even have to think about. If I take enough time and put any amount of effort into it, I could come up with some SERIOUS problems for my protagonist.
So go out, learn from someone's mistakes (even your own), and use them to create real, flawed characters that readers can relate to.