These buttons have little black plastic flags at both ends that close OFF the optic beams.
When you push down on the cap, flags go down below about a 1/4" to clear and OPEN the optic beams - to signal back to the MPU that a button is pushed.
Often, one of the spring-loaded legs are broken, thereby causing a flag to block an optic beam...so sometimes it works, or times no.
People bang on that Repeat/MAX bet too hard.
The four legs are positioned directly underneath 4 molded flat corners of the clear lense cap.
You cans see the left optic flag between the two left legs pretty clearly.
You may need to take it apart and see if any of the legs are broken.
Unfortunately, I haven't found anyone that makes replacement actuators at all.
Strange that yours works in the tests tho...IDK why?

Here's a drawing I made of one that I have with a broken leg I drew in red...>>>