Iirc the zombies run directly to you if there are no obstacles in the way.
If you are in a base or on top of something or obstacles around you, they will do a pathfinding to you and follow that path, because there is no way to go directly to you.
E.g if you standing on top of something, they will head to the ladder, ramp or what ever way they find up to you. If there is no way directly doable, they will find a way with the least resistance. So eg. if you are standing inside a cage of iron bars and one wooden door, they will go for the door.
And some of the Zs may enter "rage mode" and run around randomly and also attack random blocks.
And maybe the zombies are not that braindead to run in a straight line up to somebody who is shooting at them, but they run diagonally, BECAUSE it is harder to hit them this way.
Edit: I noted if the ground is a slope, that seems to affect pathing. It seems to cause the Zs to run parallel to the slop and then turn 90° and run directly uphill. I guess this is calculated to be faster, because parallel to the slope their runway is even and the way to go upwards, which also slows down zombies, becomes shorter.