I'm new to game programming, so please excuse the basic question. As I understand it, a game runs a main loop that updates the world frame by frame, with collision detection somewhere in that process. Couldn't the map be represented mathematically, with the game checking whether the player has crossed a boundary and pushing them back inside when necessary? Why do so many games still let characters clip through walls or escape the intended map?
4 Answers
Floating-point numbers are another source of trouble. Positions and distances are usually approximations, and repeated calculations can introduce small errors. Those errors may cause a character to be considered just inside or just outside a surface, especially when several collision corrections happen in the same frame. Some games do include safety checks that teleport, kill, or reset a character after they leave the valid area, but those checks can be incomplete or intentionally avoided for gameplay reasons.
Collision is usually based on simplified surfaces rather than treating the entire world as a solid volume. Game levels are commonly built from many triangles, so creating one perfect mathematical function for every wall, cave, object, doorway, and terrain feature would be impractical. A game can use more complete volume checks, but they cost more and still have to handle doors, triggers, teleport areas, moving objects, and other special cases.
The visible level and its collision geometry are often different. Developers may use invisible boundaries, simplified hitboxes, or special rules for doors, caves, triggers, and objects that should be passable. Large, complicated maps have countless combinations of terrain, physics, characters, and scripted events, so testing every possible interaction is extremely difficult. Small level edits can also create tiny gaps that nobody notices.
A common problem is movement speed. If a character moves farther in one frame than the thickness of a wall, the collision test may check the starting and ending positions without noticing that the character passed through the wall. More advanced systems sweep the character’s shape along its path, but that is more expensive. Physics corrections can also interact badly: one system pushes the player out of an object while another moves them again, and a single bad frame can leave them on the wrong side.

Related Questions
How To: Running Codex CLI on Windows with Azure OpenAI
Set Wordpress Featured Image Using Javascript
How To Fix PHP Random Being The Same
Why no WebP Support with Wordpress
Replace Wordpress Cron With Linux Cron
Customize Yoast Canonical URL Programmatically