The name is misleading twice. A smart contract is neither a legal contract nor intelligent. It is a program stored on a blockchain that executes when called.
What makes it different from ordinary code
It runs on many computers that all verify the result, so nobody can alter the outcome. Once deployed, it generally cannot be changed. And it can hold and move funds directly.
The consequence is that the code is the agreement. Whatever it does is what happens, regardless of what anyone intended.
What it is good for
Automatic execution where the conditions are unambiguous and verifiable on-chain. Releasing funds when a condition is met. Exchanging one token for another. Distributing according to a fixed rule.
Anything where you would otherwise need a trusted intermediary to hold something and release it on agreed terms.
What it cannot do
Know anything about the outside world. A contract cannot check whether goods arrived or whether it rained. That requires an oracle – a service feeding external data in – and the oracle is a trusted party, which reintroduces exactly what the design was avoiding.
Handle ambiguity. Legal contracts contain reasonable-efforts clauses and get interpreted by courts. Code has no such capacity.
Where the risk is
Bugs. Hundreds of millions have been lost to flaws in deployed contracts, and because the code is immutable and the transactions irreversible, there is no remedy.
Audits reduce this and do not eliminate it. Several audited contracts have been exploited.
The honest framing
Useful for narrow, well-defined, verifiable conditions. Dangerous when used for anything requiring judgement.