\(M=\left(1+\frac{a}{a^2+1}\right):\left(\frac{1}{a-1}-\frac{2a}{a^3-a^2+a-1}\right)\)
\(=\left(\frac{a^2+1}{a^2+1}+\frac{a}{a^2+1}\right):\left(\frac{a^2+1}{\left(a-1\right)\left(a^2+1\right)}-\frac{2a}{a^2\left(a-1\right)+\left(a-1\right)}\right)\)
\(=\frac{a^2+a+1}{a^2+1}:\left(\frac{a^2+1}{\left(a-1\right)\left(a^2+1\right)}-\frac{2a}{\left(a^2+1\right)\left(a-1\right)}\right)\)
\(=\frac{a^2+a+1}{a^2+1}:\frac{a-1}{a^2+1}=\frac{a^2+a+1}{a-1}\)