Since the flavour of the spell is that you're trapped within something dangerous and interacting with it hurts you, it makes perfect sense that no longer being trapped without interacting with the dangerous thing frees you with no damage, just like teleporting out of any real situation would.
There's also the fact that teleportation is never ever referred to as movement anywhere within the rules, which has some important implications: Your teleportation distance isn't reduced by difficult terrain, you can't mount up by teleporting. You can't stand up by teleporting. You can't jump, climb or swim while teleporting. You can teleport through intervening objects...
In general, the rules for teleporting and the rules for moving are not the same. The only similarity they share is "your position at the end of the teleport may be different to your position at the start of the teleport".
Well, I can agree with you that teleporting and general movement are different. I understand what you're saying.
But using that with Mental Prison hinges on focusing on the word "move" in the spell text vs. what I would say is the content of the text, that leaving the illusionary prison triggers damage.
Flavor-wise you could explain any situation in any different way. The danger of the prison may not be perceived as physical that can be avoided, but a spiritual or psychic threat (the damage is psychic, after all) requiring you to stay within the prison.
I will have to keep my eye out for other instances of "move" in the books and see how this fits in with teleporting-type movement.