Using the setblock command to replace a button creates multiple possible problems.
How to recreate:
1) Press a button
2) Before the button becomes unpowered, use setblock to replace it with another button or block
Possible issues:
1) A powered button cannot be replaced by a new powered button unless it is a different type of material. In that case, it will replace the button but maintain the amount of time the button has been pressed. This means that you can not replace a powered button and make it stay pressed.
2) Replacing a powered button with a different block and then switching it back to a powered button has the same issue where it remembers how long the button was pressed for.
3) In some circumstances, when the replaced button returns to being unpowered it is not recognized by the game as being in that state. Pressing it once will not provide an update, but pressing it a second time returns it to normal. This one is much harder to recreate.
Related issues
Comments

Thank you for your report!
We're tracking this issue in MC-31100, so this ticket is being resolved and linked as a duplicate.
If you would like to add a vote and any extra information to the main ticket it would be appreciated.
If you haven't already, you might like to make use of the search feature to see if the issue has already been mentioned.
Quick Links:
📓 Bug Tracker Guidelines – 💬 Community Support – 📧 Mojang Support
📓 Project Summary – ✍️ Feedback and Suggestions – 📖 Game Wiki