The following illustrations are from a pinball machine repair manual.
What purpose does the diode perform on the lamp and switch?
See the wires labeled "row" and "column"?
What you have there is detail drawings of single cells of matrixed switches and lamps.
The purpose of the diode is to steer the current though the addressed devices only, by disallowing detour paths.