Always use code-tags when posting any code.
There’s no point doing this kind of code per-frame when the physics isn’t running (by default) per-frame. By default, you should do this in the FixedUpdate callback because otherwise, you’re wasting CPU time.
Maybe it’s because the object is moving too fast and because you’re using Discrete collision detection on the Rigidbody, it’s stepping over the “walls”. If the walls were deeper and/or you use one of the Continuous collision detection modes then it’d likely stop it from tunnelling.