Adam improperly ate from the fruit of the tree; as punishment the ground is cursed and can only be farmed through hard labor. Kayin was a farmer who killed a herder; as punishment he is even further divorced from the land; specifically he is forced to take up a herder's lifestyle.
In verses 4:18-24 we read about Lemech (the first person by that name). He is notable for his kids beginning careers: livestock herding, music playing, instruments of war. He is also noted for his poem to his wives: unlike Kayin he did not kill anyone, so his protection is greater than Kayin's. Each of his wives had one son with a money-earning career (herding/war), then one child with presumably no productive career (the music playing son/the daughter Naamah).
Herding, and being a warrior (or hunter, or tool-seller), are stereotypical careers for someone divorced from the produce of the land. It makes sense that Lemech in particular would direct his sons to these careers, since he is aware of the curse which Adam and Kayin had incurred. (This awareness is clear in his poem, and is also indicated in the name Tuval-Kayin.)
Meanwhile, the OTHER Lemech (descended from Adam's son Shet, not Kayin) names his kid Noach, hoping that the kid "will comfort us from our doings and from the sadness of our hands, from the ground which God has cursed" (5:29). And in fact Noach does eventually overcome the curse of the ground, embarking on a (too successful!) agricultural career with his vineyard. The phrase "our doings" in second Lemech's naming may refer to sin: he hopes Noach will rescue them from the curse on the land, which Adam incurred upon sinning.
We see that both Lemechs were unique in their families, in that they dealt so actively with the curses placed on their ancestors. Nobody likes being cursed, and everyone tries their best to avoid curses. But the two Lemechs were presumably uniquely talented or imaginative, so their attempted solutions are recorded for posterity.
However, there is an important difference in HOW the Lemechs dealt with the curses. The first Lemech, realizing that agriculture was no longer productive, apparently trained his kids to pursue a range of alternative careers. God had intended the land to be cursed as punishment, but the punishment could be avoided if one did not live on the land. In a sense, first Lemech tried to subvert the Divine curses. Mankind still deserved to be punished, but in effect one could thwart God's will by avoiding the setting in which punishment was inflicted.
Second Lemech's approach is drastically different. It is not immediately clear what exactly his approach consists of, since no action is ascribed to him after he names and ascribes destiny to Noach. But by looking at how Noach turned out you can deduce what second Lemech was referring to. Specifically, Noach is the first human to be called "tzadik" - righteous. (Whether he is perfectly righteous on Avraham's level or not is irrelevant; he is clearly better than his predecessors.) Second Lemech intended the curse to be removed through the righteous behavior of his son. Noach would repent, and perhaps lead the whole world to repent, and God would have no more reason to curse the ground. What a contrast from first Lemech, who made no attempt to improve his behavior, but only to take practical steps to avoid the effects of the curse!
From this perspective, it is no wonder why first Lemech's family died in the flood, and no wonder why part of second Lemech's family merited to survive it. Even Noach himself is by no means morally blameless, as we see shortly after the flood. But instead of trying to evade God's judgment, he recognizes and confronts it. Even someone who was and will remain imperfect, like Noach, finds that this path leads him in the direction of concrete spiritual accomplishments.