Hash functions have features that secure for instance Bitcoin. A hash function always gives the same output when the input is unchanged. Change the input even a little and the output changes. Hash functions are irreversible. You can’t deduce the input from the output. It would take a very long time of brute-force trial and error to find the input.
Hash functions secure the network and each Bitcoin by making it infeasible to uncover private keys of Bitcoin holders. Secure Hash Algorithm-256 is used as the Proof Of Work algorithm in Bitcoin mining.
Theoretically two different inputs can result in the same output. Because of collision resistance it will take an astronomically long time to find to distinct inputs, messages, that give the same output.