A quote I found particularly helpful in regards to understanding the meaning of the word “generation” in Scripture comes from St. Jerome, as cited by St. Thomas Aquinas in his Catena Aurea commentary on this passage in Matthew:
The rule of the Scriptures is only to know two generations, one of good the other of bad. Of the generation of the good it is said, “The generation of the righteous shall be blessed”. And of the bad it is said in the present passage, “Generation of vipers”. These then, because they did against the Apostles like things as Cain and Joas, are described as of one generation.Once realizing that “generation” can also be understood with this meaning (good/evil rather than length of time), there are other passages as well in Scripture that make more sense or acquire an added and deeper meaning. (Eg. Mt. 24:34; Mk 8:12; Luke 7:31; …)