They swim towards where they feel water flowing from. They keep going until their bodies are breaking down. Fish at the spawn location often have rotting bodies, even as they still live - losing color and with their flesh changing consistency.
That part is not really known. Various things have been suspected like memory of magnetic fields, salinity, temperature patterns, odors, etc. Basically they may be memorizing those on the way out and end up coming back to the same shoreline. From there itβs following upstream water pressure (which is how salmon ladders induce them to follow the ladder).
Do rivers have a smell? Animals have a keen sense of smell and the volume of rivers is enormous. Seems like a random-walk sniffing for rivers would be effective.