A keyboard is scanned by pulsing each row individually and checking which columns become active because a pressed key connects them. (Or vice versa.)
In (2), when the green row is pulsed, only the green column becomes active, because it's connected to the green row by the pressed key (upper left red dot).
In (4), when the upper of the two green rows is pulsed, both the green columns become active — the first because the upper-left red dot is pressed, and the second because there is a path through all three of the red dots (pressed keys). So the keyboard senses a key press at the dotless intersection, even though that key is not pressed.
Better keyboards solve this problem with a diode on each key, so that the roundabout path can't happen. Cheap keyboards rearrange the rows and columns into squiggly paths so that the three-key pattern doesn't happen very often, being especially careful with the modifier keys.
Ghosting on a discrete contact-switch keyboard is inexcusable, of course.
I am not sure about costs, though, I did not consider membrane keyboards for my research. Membranes are extremely cheap. Not just because of the membranes being cheap but also because there is no assembly (PCB is contacts, no assembly required for switches) and because there might not be need for double-sided PCB. In this case diodes could force double-sided PCB, vias, and maybe even double sided assembly.