The top picture shows, in symbolic form, one of the most basic forms of electronic switch. In this picture, a voltage has to be applied to both 'IN 1' and 'IN 2' before a voltage appears at the 'OUT' side. Note the & symbol to signify an "and gate ".
There's another kind of gate which needs 'IN 1' or 'IN 2' before the voltage appears at the 'OUT' side - called (guess what!) an "or gate ".
There are dozens of different combinations of switches each with differing input requirements in order to produce an output.
Using these electronic switches is so commonplace, manufacturers supply them in "pre-assembled" packages known as integrated circuits which can contain anything from three or four to, literally, thousands of individual switches arranged to perform specific tasks.