This would be a Brick Joke and/or Fridge Brilliance, which are two related concepts. The first is a a joke that follows a common formula where the first joke involves a brick falling from a great height... followed by a series of unrelated jokes... followed by a joke that starts off just as unrelated, but the punch line is the subject of the joke getting hit by the falling brick. When don subtlely, it can result in Fridge Brilliance, which is basically, when you can't put your finger on why something was done in a movie... until one night, when you go for a late night snack and upon opening the fridge, a light dawns upon you and you get it*.
Despite the former's name, it need not be a joke, but that the information set up by perfectly valid dialog early on pays off later when it's brought up again that may stump unobservent people. For example, there are two ways to watch the Sixth Sense: A first time watcher and a person who is looking for the tricks. It's not funny, but almost every scene hints to the big reveal.
Another great example is the film "My Cousin Vinny" where the titular cousin is defending two kids who are being tried for a murder they did not commit. Vinny is allowed to ask the three eye witnesses in the prosecution's defense and asks a single question of each witness that at the initial presentation, have nothing to do with disproving the murder and seem kinda stupid to ask on their face and highlight the humor up to this point of Vinny being a bad lawyer who doesn't know what he's doing ("What did you have for breakfast?" "How long have you been wearing those glasses?" "What is that on your window?")
However, come the actual trial, the answer to these questions actually undermines all the witnesses. The first witness (breakfast) had just begun cooking his breakfast when he saw the defendants enter the scene, but was eating when the defendants left the scene (and couldn't identify them). He testified that it was 5 minutes in total, but his breakfast took 15 minutes to cook, thus his time line was wrong and he didn't have unbroken eyes on the scene.
The next witness (glasses) had worn glasses since she was good and had gone through several different pairs as her vision got worse over the years. Turns out, she was well overdue for a stronger prescription and couldn't make out details at half the distance she testified the she saw the defendants.
The final witness (window) had a dirty window with a rusty screen that looked out to several bushes and trees that would have obscured his vision of the crime scene and called into question his ability to identify the scene.
In this example, all three earlier questions became vitally important later (Brick Joke) and for most movie watchers, it's only relevant well after they've watched the movie several times. And without spoiling, the dramatic conclusion is built on facts that viewer knew since the first scene to feature Vinny onscreen.
The final film that does this well is Hot Fuzz, which, well, pick a line in the first half of the movie... it will be important in a joke or gag later in the film.
*Oh, and in case you missed it, this is not only a definition of Fridge Brilliance, but also an example: How many of you caught the pun of opening a Fridge only for the light to dawn on you as you finally get it (the snack? the gag? The pronoun is a bit ambiguous in what it is specifically referring to).