PCF8574AN configured as output for relay

What I gave you was two functions to turn on and off individual bits in your interface.

clearOutput(4);
also where to put those

You put them in your code when ever you want to turn something on or off. Specifically when you want to turn bit 4 off. If you want to turn bit 1 off you would put clearOutput(1) ; if you want to turn bit 6 off you would use clearOutput(6) ; if you want to turn bit 8 off then you understand even less because there is no bit 8 in your interface.

The code you just posted is a nonsense, it contains a function definition in the middle of a function, that does not make sense and the compiler no doubt tells you so. The functions I gave you must be put separately at the end of your code. Then in the code you call the functions when ever you want to turn something on or off. That will be turned on or off without affecting any other things attached to the same expander. Which is what I thought you wanted.

I don't think you know enough about programming to do your project. I would advise you learning some very basic fundamentals of programming. Like what is a function.