I do not know why I can not compile your code, it seems to me that there are rare characters in it (inputtenc Error: Unicode character ...), however I use another framework.
Here a MWE with three examples: in green using the nodes defined in the matrix; in red according to the code you sent, where you can see the error, then in blue, how can you get what you want by the code you sent method ...
RESULT:
MWE:
\documentclass[tikz,border=14pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{matrix,shapes,decorations.pathreplacing,fit,backgrounds}
\begin{document}
\begin{tikzpicture}[
%Styles
Matrix/.style={
matrix of nodes,
text height=2.5ex,
text depth=0.75ex,
text width=3.25ex,
align=center,
left delimiter={[},
right delimiter={]},
column sep=0pt,
row sep=0pt,
%nodes={draw=black!10}, % Uncoment to see the square nodes.
nodes in empty cells,
},
DA/.style={
fill=green!10,
dotted,
line width=0.7pt,
rounded corners=5pt,
}
]
\matrix[Matrix] at (0,0) (M){ % Matrix contents
1 & 3 & -8 & 5 \\
2 & 0 & 1 & 7 \\
7 & 9 & 1 & 2 \\
7 & 9 & 1 & 2 \\
};
\matrix[Matrix,nodes={draw=black!10}] at (4,0) (M1){ % Matrix contents
1 & 3 & -8 & 5 \\
2 & 0 & 1 & 7 \\
7 & 9 & 1 & 2 \\
7 & 9 & 1 & 2 \\
};
\matrix[Matrix] at (8,0) (M2){ % Matrix contents
1 & 3 & -8 & 5 \\
2 & 0 & 1 & 7 \\
7 & 9 & 1 & 2 \\
7 & 9 & 1 & 2 \\
};
\begin{scope}[on background layer] %Allows to draw in background layer.
%FOR MATRIX M
%To delimit area groups using matrix nodes
\draw[DA](M-1-1.north west)
-| (M-4-4.south east)
-- (M-4-4.south west)
|- (M-3-3.south west)
|- (M-2-2.south west)
|- (M-1-1.south west)
-- cycle;
% Method for your example
% In red some mistakes
% Fit creates squared nodes
%\node[styles](ID){Text};
\node[inner sep=2pt,draw,red,fit=(M1-1-1)](fit1){};
\node[inner sep=2pt,draw,red,fit=(M1-1-2)(M1-2-3)(M1-3-4)](fit2){};
\node[inner sep=2pt,draw,red,fit=(M1-4-4)](fit3){};
%If you trace the draw:
\draw[DA,fill=red,fill opacity=0.2](fit1.north west)
-- (fit2.north east)
|- (fit3.south west)
|- (fit2.south west)
|- (fit1.south west)
-- cycle;
% Correcting using the method you use
\node[inner sep=2pt,draw,blue,fit=(M2-1-1)](n1){};
\node[inner sep=2pt,draw,blue,fit=(M2-2-2)](n2){};
\node[inner sep=2pt,draw,blue,fit=(M2-3-3)](n3){};
\node[inner sep=2pt,draw,blue,fit=(M2-4-4)](n4){};
%If you trace the draw:
\draw[DA,fill=blue,fill opacity=0.2](n1.north west)
-| (n4.south east)
|- (n4.south west)
|- (n3.south west)
|- (n2.south west)
|- (n1.south west)
-- cycle;
\end{scope}
\end{tikzpicture}
\end{document}