I don't think there's a certain number of years... I have Connection Tamagotchis 8 years old but the buttons work perfectly. Just clean them when they seem unresponsive.
I'm not sure. I guess it depends on how well you take care of them. I've had a couple of my Tamagotchis for at least 7 years, and the buttons still work fine.