Why should I never store passwords in plain text?
If passwords are stored as written, anyone who obtains the database obtains every account immediately. That includes an attacker exploiting an unrelated vulnerability, a backup left accessible, or an employee with database access. The damage also extends well beyond your service, because people reuse passwords, so your breach compromises their email and banking too.
The correct approach is to store a hash: a one-way transformation you can verify against without being able to reverse. At login you hash the supplied password and compare, so the original is never stored.
The details matter more than the principle, and getting them wrong is common.
General-purpose hash functions such as SHA-256 are the wrong tool despite being cryptographically sound. They are designed to be fast, and speed is exactly what an attacker wants: modern hardware computes billions per second, so a stolen database of fast hashes falls quickly to brute force.
What you want is a deliberately slow algorithm designed for passwords, with a tunable work factor so it can be made more expensive as hardware improves. Argon2 is the current recommendation, with bcrypt and scrypt remaining acceptable and widely available.
Salting is essential and handled automatically by these algorithms. A unique random salt per password means identical passwords produce different hashes, which defeats precomputed lookup tables and prevents an attacker learning that two users share a password.
The strongest practical advice is not to implement any of this yourself. Use your framework's password hashing facility, or delegate authentication entirely to an identity provider. This is a well-solved problem where custom implementations reliably introduce subtle flaws.