I believe that it is due to an old tale where salt would magically cure a vast majority of bacterial, external parasite, and some fungal infections due to its properties (and the fact that anything in freshwater really isn’t designed to handle salt at any level). It’s a very common medicine used for general cures due to this, however it can be pretty dangerous if used too frequently (you’ll turn your freshwater tank into a brackish tank, or kill off any snails and plants you may have) and tends to be recommended very incorrectly. A lot of people tend to recommend the same amount no matter what fish you have, which some fish are more or less salt tolerant up to specific levels.
Is it a generic cure all? No - but it can help with a lot, cure more things that most medicines can (since they are very specific), and does help time to time by allowing for the fish to generate a new, thicker slime coat.
Are all salts the same? No - there are a few different salts out there that all do specifically different things (for example table salt is not the same as marine water salt). All salts have different compounds o minerals in them that provide a benefit to a specific set of aquatic animals that one may wish to keep in their aquarium.
Should it be used all of the time? No - since things are freshwater for a reason (and not in brackish water), along with it having dangerous effects to invertebrates who are used to living in absolutely no salt. Plus, other fish can have an extremely hard time processing the salt which can cause for them to slowly die off.
Do you need salt in your tank? No - I’d only recommend it if you have a known bacterial, fungal, or external parasite that will die from the addition of salt. Otherwise, I’d note to stay away from it all together.