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

There is one thing that re­ally striked me af­ter read­ing HPMOR, it’s a cer­tain pat­tern of events that re­peats many times.

1) Harry gets into grave trou­ble due to his self-as­surance and indiscretion

2) The au­thor saves Harry us­ing deus ex machina

And this makes me won­der—was Harry in­ten­tion­ally shown as an anti-ex­am­ple of ra­tio­nal­ity, or it just hap­pened this way?