Epigenetics. It's the make-file for your genetic source code. Certain conditions can cause certain parts of your genetic code to be uncommented or commented-out. There are actually a number of different kinds of comments (histone modifications [1]) - each set of marks particular to a different compiler, in different contexts. And these comments/marks are copied with some fidelity to daughter-cells/children along with a high-fidelty copy of the underlying genetic code itself.
So the genes themselves are not being heritably altered, rather the recipe for which gene is where, when can be subtly changed. But again, the same mechanisms that permit the change in expression of those genes during a lifetime can be subsequently changed in the next just as easily.
In this way you can store the code for some trait or capability over many generations without having it always be running. It can manifest itself in individual organisms as having very different phenotypes even with the same underlying code.