A contract is an agreement, an arrangement between people. States, companies, associations and other organisations can also conclude contracts. Sometimes people think of a contract as the agreement itself, sometimes they think of the piece of paper on which the agreement is written.
In a contract, someone promises to do something. If you want to sell a house, you make a contract with the buyer. The contract says, for example: the buyer has to pay money, and the seller gives him the keys to the house in return. The buyer and the seller are contracting parties. They sign the contract.
You have to stick to a contract. Otherwise you can be punished by the state. However, the contracting parties can decide together to dissolve the contract. Then they no longer have to abide by it.
Sometimes a contract is invalid, in which case you no longer have to abide by it. Whether that is the case is ultimately decided by a court. The contract can be invalid because a contracting party lied: Maybe the seller didn't own the house at all.