If the maze is not simply-connected (i.e. if the start or endpoints are in the center of the structure surrounded by passage loops, or the pathways cross over and under each other and such parts of the solution path are surrounded by passage loops), this method will not necessarily reach the goal.
How I learned that all mazes can be solved if you hug one of the walls
that only works for mazes without islands if I recall correctly
Not necessarily all mazes:
https://en.m.wikipedia.org/wiki/Maze-solving_algorithm#Hand_On_Wall_Rule
Assuming there are no loops in the maze.