Minimum time for digital signal reading

I don't understand that you can't see how they are being read first and the result is used just 1 line below. If you say it does not do anything, how come I can trigger the relays for 2 seconds when I ground pin S1? Both "if" statements work just fine! Is my approach that uncommon?