This is, I think, one of the deepest arts in user experience design. It comes up in games, but I find myself applying it all the time when designing a programming language too.
A human sitting at a machine and pushing buttons is expressing some sort of intention. When the machine can do exactly what they requested, easy, do that.
But what happens if their intentions don't seem to make sense given the current state of the system and/or their previously indicated intentions?
In the context of Tetris, it's them trying to rotate a piece when they've moved it too close to the wall to do that. In a programming language, it can be that they've defined a function that's declared to take a string and then they wrote a call that passes it a number.
Sometimes, you can make a pretty confident guess as to what they are trying to do and have the system either do that instead or at least use that assumption to explain why the system can't do what they requested.
But deciding when a guess is a safe bet for the system to make and when it will be wrong often enough to confuse users is really hard, especially as the complexity of the system and the diversity of the userbase scales up.