When it behaves exactly as you expect (after coming to understand how it works, if it's not immediately obvious), then the code will in some way be 1:1 with the user mental model (bearing in mind that there may be many ways to express that same model).
For example, you'll find code (or a refactoring if the equivalent code) that reads like "Money transfer is: select a source account, a destination account, and an amount, decrease the source account by that amount, increase the destination account by that amount. This must succeed or fail as a single transaction".
Only when there is a mismatch between the user mental model and the programmer's mental model, does software do things you don't expect and perhaps cannot understand (talking about designed behavior, not bugs and technical limitations). Ever find yourself having to figure out what the heck the program is thinking, because it's obviously not what you are thinking? For example, pick your favorite WTF moment from almost any document editor.