> ...shouldn't it be possible that these things will be avoided by confirming the validity of the code...
It would be better to build in a margin of tolerance for correcting mistakes, but that's contrary to the rigid determinism that smart contracts and cryptocurrencies, for some reason, strive for.