Need help with loops and switches

I believe I understand your your confusion; let's walk through the journey-

You power up/ reset the arduino:
void setup runs only at boot up-
5 seconds pass - relay turns ON; Immediately, serial monitor prints ""--------------------"; Serial monitor prints "FLUSHING STARTED".

5 seconds later, Serial monitor prints "FLUSHING".
5 seconds later, relay turns OFF; Serial monitor prints "FLUSHING STOPPED".
Immediately, serial monitor prints ""--------------------".

void loop runs constantly after boot. However, you read the pin and print the value of the pin... constantly.

You have a function - "void val()"; however, it is never called to change the state of the relay.

solution:

void loop() {
  val = digitalRead(switchPin);
                       val();  // CALL THE FUNCTION
 
  Serial.println(val);

}

Note:
if (digitalRead(readingPin) == HIGH) will never be true; you never read the pin in void loop() or otherwise.