The algorithm is the same. Modern shadow-suites use pluggable authentication modules (PAM), and PAM lets you configure one hashing algorithm. It's all about "salting", which means randomizing the password to give the very effect that you're asking about.
Salting is a counter-measure to dictionary attacks, where an attacker with a dictionary of known password/hash pairs tries to find out, whether the given hash value for an unknown password matches the hash value for one of the known passwords.
Salting prevents that as a different salt value leads to a different hash value, so it doesn't matter that the password are equal. (It's nonetheless bad practice, but for other reasons.) For the dictionary attack to succeed, the attacker now has to have dictionaries for every possible salt value. A truly random salt of sufficient size will make the success probability of such an attack negligible.
Suggested reading: How are passwords stored in Linux (Understanding hashing with shadow utils)