People aren’t born knowing what to do in all situations. We learn based on what does go wrong, based on the contingencies we do encounter. Gradually.
A chess program must have all situations programmed ahead of time, an algorithm for everything physically possible. A human player encounters a situations, then finds a solution – maybe not this time, but for next.
Humans add error handling only after we encounter the error. We can do that with our programs, too. With good logging and error notification, we can teach the program how to deal with what it’s proven is a real situation.
Then our programs can be like small children: we don’t teach them how to deal with everything. We teach them how to ask for help. In a program, include visibility and monitoring from the start, add error handling later.