When I was new to chess I remember losing a game like this
-
-
And I thought oh well, that was just unlucky.
Then I lost like that again (2...f6 is a bad move) and I realized oh, I guess it's not luck. I should remember not to do this.
Then I lost like that a 3rd time, then I was really motivated to remember not to lose like that again!
That's how most lessons in chess go. First you don't know, then you know and you try your best to not do it, but you screw it up again anyway, then at some point you finally stop doing it (not every lesson is as simple as an opening trap so some mistakes take a while to eliminate).
Yes you start this way but once you learn some patterns that won't happen to you any more, you learn that playing f6 to defend e5 as the black pieces is bad because it weakens your kingside, specifically the h5-e8 diagonal, thus after the knight sacrifice the king is vulnerable to checks which is generally not a good thing.
However see my previous post, if you were new to Chess that's fine, but generally when you get hit with something like this, take it to the analysis board and see how to prevent it/refute it. Oh and btw there is no luck in chess, you either know what you're doing or you don't, nobody gets "lucky".
However to your point, when you get hit with something in an actual game, you tend to remember it more, I can still remember how my Bishop got trapped in a game I played against a 92 year old man in a diner, ...no I'm not making that up.
When I was new to chess I remember losing a game like this
-
-
And I thought oh well, that was just unlucky.
Then I lost like that again (2...f6 is a bad move) and I realized oh, I guess it's not luck. I should remember not to do this.
Then I lost like that a 3rd time, then I was really motivated to remember not to lose like that again!
That's how most lessons in chess go. First you don't know, then you know and you try your best to not do it, but you screw it up again anyway, then at some point you finally stop doing it (not every lesson is as simple as an opening trap so some mistakes take a while to eliminate).