For large enough $n$,
$$ M(n)=3M(n-1)+1\\
M(n)=3(3M(n-2)+1)+1\\
M(n)=9M(n-2)+4\\
M(n)=9(3M(n-3)+1)+4\\
M(n)=27M(n-3)+13\\
M(n)=27(3M(n-4)+1)+13\\
M(n)=81M(n-4)+40\\
M(n)=81(3M(n-5)+1)+40\\
M(n)=243M(n-5)+121\\
$$
Keep going until you notice a pattern.
Eventually you will realize that $M(n)=3^{n-1}M(1)+\frac{3^{n-1}-1}{2}=\frac{3^n-1}{2}$.
You can prove this by induction:
The base case is true: $M(1)=\frac{3^1-1}{2}=1$
Now suppose $M(n)=\frac{3^n-1}{2}$. Then $M(n+1)=3M(n)+1=3*\frac{3^n-1}{2}+1=\frac{3^{n+1}-3}{2}+1=\frac{3^{n+1}-1}{2}$. Thus we have proven that $M(n)=\frac{3^n-1}{2}$.