\(3\left(a^2+b^2+c^2\right)=a^2+b^2+c^2+2\left(ab+bc+ca\right)\)
\(\Leftrightarrow2a^2+2b^2+2c^2-2ab-2bc-2ca=0\)
\(\Leftrightarrow\left(a-b\right)^2+\left(b-c\right)^2+\left(c-a\right)^2=0\)
\(\Rightarrow a=b=c\)
\(\Rightarrow M=3a^2-3a+1=3\left(a-\frac{1}{2}\right)^2+\frac{1}{4}\ge\frac{1}{4}\)