They do try. Avionics is miles ahead of everyday commercial stuff like your desktop computer in reliability and correctness.
This is not just about software, a plane is a complex physical system and the idea of absolute control is a fantasy. This is why you need alternatives, failsafes, contingency plans, and training in dealing with unexpected failure modes.