I have a weird problem. Recently, I have noticed whenever I connect my MacBook Pro to my screen, the shutdown prompt (see picture) pops up and no matter how many times I click on "Cancel" it keeps popping up. It even steals the screen attention (that window gets highlighted) meaning that I'm not able to do anything at all. Usually, it stops after a while (like 10 minutes or more), but it is nondeterministic.
I have a theory about what can be the cause. The screen I have is one of these old Apple Cinema displays (maybe ten years old), and it has a power button (touch-based) on it. I think it must be related to this. Somehow it feels as if the button is continuously getting pressed. In the Display preferences, there is an option related to the button. It's already set to "Does nothing" but the problem still occurs. I tried changing it to "Turns the display on and off", and the display started blinking, constantly turning on and off, which proves my hypothesis is correct. However, I have no idea what this is happening and how I can stop it.