any reason why he sometimes plans to take a detour thru the water (as in the shortest path avoids the water but is not the path he takes) I found this to happen if you block off the bottom and right side waters from the inside (and putting walls on the corners) in the level where the character, flag, and a button are all in separate corners . For some reason the character would detour thru the right side waters, taking a longer path than they needed to.
The way the pathfinding works is that the game has a list of tiles to check ordered by how long the walk to them is and how close they are to the goal, then checks the 4 tiles around each of those tiles, and if they're not inside walls or such they're added to the list as well. There's a priority order in which direction around a tile is checked first, and on a map as small as this, multiple tiles are probably likely to get the same "distance from goal + distance to walk here" score. These factors can create situations where the game can favour a path that to human eye looks unoptimal.