I often wondered that if I have entered a password and someone else has coincidentally entered the same password, then after hashing the passwords would have been same. But I was wrong. There is a technique known as "salting" which, as its name suggests, adds some salt to the content (the password).

Salting in security is the practice of adding unique, random data (a "salt") to each user's password before it is hashed and stored. For robust implementation, best practices require using unique per-user salts of at least 16 bytes paired with modern algorithms and defense-in-depth techniques like peppering.

This is how salting works in steps:

Generating the salt - it uses CSPRNG which is Cryptographically Secure Random Number Generator, creates a unique, random string for each user account.

Combine password and salt - note, that this step is done before hashing which makes the hashed passwords different.