The one with the storytelling looks more like a plot twist, where an important clue is withheld until the end.
Both a plot twist and a joke have in common some element of surprise. In a plot twist, the teller lays a story with all the details but one, while in a joke the teller doesn't tell the details, and lets the listener to assume/build a context, and then an outcome.
In a joke, the listener is left to imagine both the details and the outcome based on the most common expectations. Then the punch line of the joke comes, and reveals the context was not based on defaults, but on some less frequent situation. The joker deceives, lures one's mind into using the most common assumptions instead of particular ones, and thus the calculated outcome will be wrong. Also, the outcome must bring no damage to the listener, or else is not funny.
What is taken as a default for assumptions, how far a simulation will anticipate, how many possible paths are explored, what is considered harmful, etc., will differ from one individual to another, or from one population to another, so the same joke might not look funny, or might not be understood at all depending on the audience.
I suspect laughing is triggered like this: The mind continuously simulates what will come next. It does that naturally, all the time. The default assumptions and how far can we see in the future depends on many aspects. When the simulated outcome differs from reality, unless the mismatch is damaging, then the typical reaction is laughing.
Why laughing after that, IDK, maybe it's just joy for not taking any penalty after a wrong prediction. Nature shows no mercy if we miscalculate (e.g. imagine a miscalculated jump over an obstacle), so a miscalculation from which we take no damage could be a good reason to bring joy and celebrate by laughing. Not sure how a sudden exhale and all the rest of the physical laughter might help, though.

Anyway, the last two paragraphs were an ad-hoc attempt to find the components that make one lough, seen through the perspective of some theory of mind I am fiddling with (mind as an oracle, with the sensory inputs used to minimize the simulation errors). Might be incorrect, but to sum it up: The laughter reaction is triggered when the mind simulation was made as usual, but the reality begs to differ this time, yet no personal damage was taken.