It's not a genetic memory. They return to the place they were born. This is probably based on the "scent" of that place, and maybe other factors.
Some percentage either accidentally or deliberately go up a different river, which is how the species spreads. That's very likely who this story is about.