Droid technology is one of several Star Wars technologies that pre-dates the Republic. Both the Rakata and the Gree had droids. Given the Rakatan obsession with Force-based technologies, something droids explicitly are not, it seems probable that droids were invented by the Gree, stolen by the Rakata, and only later adapted by Humans and other species that developed into the Republic civilization. Being six-limbed cephalopods with an extremely non-Human mental architecture, Gree technology can only ever be imperfectly understood by Human-like minds. As such it is entirely possible that the fundamental basis of droid programming, like the fundamentals of hyperdrive, are only imperfectly understood by even the best minds of the Republic. That would explain a great deal of the variation and inconsistency found in droid programming, it's ultimately cargo-cultist in origin.