There is a known navigation issue for the Nav2 planner stack.
While navigating, the Robot looses or resets the costmap it created previously. Nav2 path planner creates a path through the wall and hits it.
It is a known bug in Nav2 path planner and similar to what has been reported at: https://github.com/ros-planning/navigation2/issues/1999
A patch will be available soon to fix the issue.