Why is backtracking a necessary step in the Maze problem?
Your question title doesn't match your question details.
You're not asking why backtracking is necessary, but you're asking why a cell marked in the matrix needs to be unmarked when backtracking.
A general technique for solving questions like this is as follows.
We'll investigate statements about the state of the program. In this case, statements about the contents of the matrix.
We start by looking at the intended outcome: the required postcondition. A postcondition is a statement that must always hold after the program terminates. In this case: what is the matrix supposed to contain after the program terminates?
The answer: the cells of the matrix must mark a path found from start to finish, if such a path exists. All cells marked 0 must be off that path, and all cells marked 1 must be on it.
Then, we figure out which invariant the program maintains in order to achieve the required postcondition. An invariant is a property that always holds: before, while, and after the program runs. In this case: which cells are supposed to be marked 1 while the program is in progress?
The answer: they are exactly the cells of the path found from the starting point to the current cell. If the program always successfully maintains this invariant, the required postcondition will always be met.
To maintain the invariant, when you add a cell to the path, it must be marked;
and when you retrace a step, removing the last cell from the current path, that cell must be unmarked.
What if we don't unmark it? Then, the program will maintain a different invariant: namely, the matrix will mark exactly those cells that have ever been visited, whether they are on the current path or not. This is the invariant Hansel was trying to maintain with his breadcrumbs.
If you follow Hansel, after the program terminates, all cells ever visited will be marked, even those that aren't on the path that was eventually found (and such cells will exist if any backtracking occurred). The requirement was for only the cells on the path to be marked. Backtracking can actually occur, so the program will no longer always be doing what it's supposed to do: it will no longer meet its required postcondition.