Here's a dramatically simplified diagram to illustrate the principle:
If I put a voltage on pin 2, and key A is pressed, I will get a voltage at pin 1. If I put a voltage on pin 3 and key B is pressed, I will get a voltage at pin 1.
It doesn't matter if both are pressed simultaneously because I am reading them sequentially.
All you have to do is scan the keys quickly enough that someone can't "sneak in" a key press in between scans which turns out is possible with even the lowest powered hardware.