\(\text{ĐKXĐ: }x\ne1\)
\(M=\frac{a^2+2}{a^3-1}+\frac{a+1}{a^2+a+1}-\frac{1}{a-1}=\frac{a^2+2}{\left(a-1\right)\left(a^2+a+1\right)}+\frac{a+1}{a^2+a+1}-\frac{1}{a-1}\)
\(=\frac{a^2+2}{\left(a-1\right)\left(a^2+a+1\right)}+\frac{\left(a-1\right)\left(a+1\right)}{\left(a-1\right)\left(a^2+a+1\right)}-\frac{a^2+a+1}{\left(a-1\right)\left(a^2+a+1\right)}\)
\(=\frac{a^2+2+a^2-1-a^2-a-1}{\left(a-1\right)\left(a^2+a+1\right)}=\frac{a^2-a}{\left(a-1\right)\left(a^2+a+1\right)}=\frac{a.\left(a-1\right)}{\left(a-1\right)\left(a^2+a+1\right)}\)
\(=\frac{a}{a^2+a+1}\)