A whole lot more goes into it than this, but a big part of what you're talking about has to do with price anchoring. (Which is in itself a subset of anchoring[0], as theorized by Daniel Kahneman).
Thanks. I'll go to my local brewery and have a $6 beer and enjoy it. And not think twice about trying a few, then going home with a growler full, and suddenly I just paid $50.
But then I go to the grocery store and the $20 bottle of wine seems expensive.
[0]: https://en.wikipedia.org/wiki/Anchoring