Delay controlled relay sketch issues

For next time, please use code tag.

Next up a big tip, but pin numbers in a variable. Makes it much clearer what it does;

const byte InputPin = 2;
const byte OutputPin = 12;

And the trouble is with the messy part (do while). You don't need to loop, just start the countdown (save the time, write the output) once based on state change detection, not based on the state. Because comment and code don't agree here

if (BUTstate == HIGH)  // if button goes HIGH and is not noise

Correct is

if (BUTstate == HIGH)  // if button _IS_ HIGH

And let the looping be done by the loop().

And a tip for easy, grab a library like Bounce2 to do the state change detection and debouncing.