For a more cynical take on why GP's advice is bad, it also breaks down trust in communication. If I catch you trying to gaslight me once I have to run all of your future statements through a more strict truthiness parser in my head, and I'll place less trust in statements you make that are actually true. People who perceive themselves as smarter than the average bear can sometimes believe that they possess the mental prowess to lie without being caught, and this is often true, but the one time it isn't true it can have devastating effects on interpersonal relationships and communication. I don't even judge people negatively for all lies, if you lie about a detail of your personal life while in a work setting there could be totally understandable privacy reasons for that where a non-answer would have a different effect than a hard "no." But if you lie about prior decision making processes, that breaks down trust in the exact domain that we need trust in. It poisons the well, and that isn't worth a little less friction in one specific decision making process.
Trust goes both ways, if you are going to reprimand me in the future for implementing a needed feature but then go ahead and use it anyway and even take credit for it then I will gaslight you next time the same problem comes up.
I don't know all the details of your specific situation, but from what I've read it does seem that your superior was in the wrong. As others have noted, this is a situation where it might be clever to look for a new employer. That being said I don't think passive aggressive lies and manipulation are a smart response. I also don't think that the actions of your superior break down communication in the same way that gaslighting does. Reprimanding somebody while still eventually using their idea can be recognized as an asshole move whether or not it affects "trust." Being an asshole isn't a great trait in a work environment, or life in general for that matter, but I know plenty of assholes who I still probabilistically trust not to lie to me. Finally, and I'm not saying this is the case in your specific negative experience, I can imagine scenarios where some light reprimand might be useful even if the idea implemented is ultimately accepted, like, "hey, that was a good idea, but it affects something above your paygrade and we really want you to go through this process[0] when making these sorts of decisions in the future." I don't think that applies to your back buttons, but I can imagine scenarios where accepting an idea while lightly reprimanding a failure to communicate during the decision making processes could make sense.
Edit: I can see how the "and even take credit" part breaks down trust in a similar way. I still don't think further trust-destruction is a clever response. I would leave, call them out on the lie, or (if not in a position to risk unemployment by pissing off a superior) bite my tongue and try to rise through the ranks.
Retribution is a terrible concept to bring into your workplace relationships. Two wrongs don’t make a right, try to take the high road. Cliché but true.