Patchers vary in complexity. But the basic idea is that they follow a three-step process:
Identify what is already present.
Formulate a plan to convert that to the desired result.
Execute that plan.
In the simplest form of patcher, one file is replaced by another. The existing file is usually identified by a checksum or hash to ensure that the patch should be applied. Then the old file is replaced with the new file, often stored in the patch file in compressed form.
More sophisticated patchers can analyze the existing file(s) and recognize versions that it can update to the version it patches to. They can then used 'diff' files that efficiently describe the difference between two files.
Some patchers can even build a checksum of all the files present on the system and then upload them to a central site which can then create a 'diff' specifically for that combination. Files recognized from previous versions will trigger a 'diff' for that file to be included in the package. Files not recognized (or those for which a compressed 'diff' is not available) will result in the entire new file being downloaded.
But the basic process is simple, remove the old, install the new.