Ta có
\(M=\left(1+a\right)\left(1+\frac{1}{b}\right)+\left(1+b\right)\left(1+\frac{1}{a}\right)=2+\frac{a}{b}+\frac{b}{a}+a+b+\frac{1}{a}+\frac{1}{b}\)
\(\ge2+2+a+b+\frac{4}{a+b}\)
\(=4+a+b+\frac{2}{a+b}+\frac{2}{a+b}\)
\(\ge4+2\sqrt{\left(a+b\right).\frac{2}{\left(a+b\right)}}+\frac{2}{\sqrt{2\left(a^2+b^2\right)}}\)
\(=4+2\sqrt{2}+\sqrt{2}=4+3\sqrt{2}\)