Stated briefly the principle is that if a porous partition separates dilute and concentrated solutions then the dilute solution permeates through the porous partition into the concentrated solution. This process does not stop till the concentration of both the solutions is equal. Salt water is more concentrated than the water in bacteria. Once such water comes in contact with the bacteria, they gradually lose their body fluid. They can not remain active after dehydration and wither and die before long.
Answer to the question as to whether salt water fish can remain alive in fresh water and fresh water fish can remain alive in salt water is contained in the above explanation. The nature has covered bodies of both kinds of fish with skin which allows only one way traffic of osmosis. Dilute body fluid of sea water fish does not ooze out to mix with the concentrated fluid, i.e. sea water. So the sea water fish do not dehydrate and wither away like bacteria. Similarly the skin of fresh water fish does not allow dilute river water to seep into its body. The skins of both fish permit only one way passage.