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.
> Avionics software is embedded software with legally mandated safety and reliability concerns used in avionics. The main difference between avionic software and conventional embedded software is that the development process is required by law and is optimized for safety.