That was intentional, it was to prevent Baldi from being stuck in a corner since the player can outrun him. So if the player got Baldi stuck in a corner and moved far away enough, he'll move through the walls to get unstuck.
NGL when I saw Baldi noclip through the wall it looks like he cheated but when I saw your comment I didn’t know that it was intentional I thought it was a bug