Hash functions work by encrypting a set of numbers/words via a function where it is infeasible to find the input with the output. One of the most important aspects of hashing is its deterministic characteristic. That means that any input will give out the same output every time.
In Bitcoin, the hashing function used is SHA-256. This means that there are 256 bits in the output. Miners use a segment of the known partial input to solve the puzzle of the output hash target. The first miner that solves the hash target receives Bitcoin as a reward.
When we say that hash functions need to be collision resistant, this means that two hash functions cannot equal one another so that someone else cannot forge a signature. This is unlikely to happen because there are 2^256 possible hashes.