[Question] [HPMOR] Harry—example or anti-example?

There is one thing that really striked me after reading HPMOR, it’s a certain pattern of events that repeats many times.

1) Harry gets into grave trouble due to his self-assurance and indiscretion

2) The author saves Harry using deus ex machina

And this makes me wonder—was Harry intentionally shown as an anti-example of rationality, or it just happened this way?