Smart contracts are a type of software programme conceptualized by Nick Szabo in 1994. They are software programmes that act autonomously on the internet to execute certain roles to aid in economic transactions, agreements between people and businesses, and to power applications.
One of the original examples that Nick Szabo proposed for the function of smart contracts was to serve as autonomous escrow agents. For example, when two parties would be engaged in a transaction, the buyer would deposit the money for the payment in advance in a smart contract, then the seller would deliver the product or service agreed, and when the smart contract saw this delivery it would pay the money to the seller, but if there was no delivery, then it would return the money to the buyer. In this fashion, the transaction would be secure for both sides, but it would not require the use of a trusted third party, such as a bank or lawyer to perform these tasks.
Blockchain networks are optimal for smart contracts because they enable these programmes to exist and work autonomously and in a decentralized way. However, smart contracts can only exist inside programmable blockchains such as Ethereum or Ethereum Classic.
The software programmes that comprise smart contracts become decentralized when they are sent to blockchains because they are replicated in all the machines participating in such networks.
As smart contracts may power applications, and because when they are sent to blockchains they become decentralized, these applications are called decentralized applications or dapps.