A notary is a person who verifies that the person who is signing a document is the person the document says. So if John Doe comes to sign a document, he has to show ID (or be someone known to the notary) so that the person notarizing it can verify it is that person. Otherwise, they could have someone else sign it and John Doe could say "that's not my signature, the contract is not valid".
You don't need every contract notarized. You don't need leases notarized. However, loan documents may require it and it is required when you buy a house.
Some other documents might require it. For example, I am looking at a job application for the federal government and they want a sworn statement to go along with it. In this case, not only does the notary verify the signature, but they make the person signing take an oath that what the document says is true. You can also have documents for court notarized, depending on the court and their rules.
A power of attorney is another thing to have notarized. If you go out of the country for a certain period of time and need someone to handle some paperwork at home for you, you might want to give them the ability to do so. That's a power of attorney and that requires a notary.
So they verify signers, take oaths, and keep a book of all their transactions.
Former notary and retired attorney.