How can I make the AI always take the shortest path?

I’m making a tower defense game where the AI has to find a path through a maze of the player’s towers and blocks. The AI should always try to take the shortest path so that the player can plan around predictable behavior. Here is a picture of the problem I’m having:

The green area is the navmesh. With no obstacles, the AI always tries to take the shortest path from waypoint 1 to waypoint 2. If I place block 1, the AI still takes the shortest path as expected. But for some reason when I place block 2, the AI wants to travel all the way around block 2 even though it has a shorter path. After placing block 3, the AI goes back to a straighter path, but it’s still crooked.

Is there a way to make AI always take the shortest path?

it always should use the shortest path by default. Click on your ground and then click P on your keyboard, you should be able to see the nav mesh. If the area between the blocks isnt green then he cant walk there and you need to move them around

Thanks, but the green area in the picture is the navmesh, and there is already a clear path.