two options:
- Battery is low
- or contacts are dirty/corroded
Try cleaning the contacts under the buttons.
Open the remote carefully, usually to get to the button contacts you will need to use a screwdriver, when you take the buttons off be careful so they do not drop and spread all around.
The contact in many cases will be metallic elements, they might have dirt on them, or some corrosion. clean it up and reassemble.
If it does not work, get a new programmable remote, they are pretty affordable nowadays.