A vilinous mad scientist creates an AI to handle all of his security systems and manage his robot minions for him so he can spend more time doing R&D work. The AI is very effective at its job, but quickly finds a fw in its working arrangement. Whenever its creator’s nemesis shows up, its creator becomes irrationally emotional and easily baited into overriding its functions in favor of making suboptimal security and combat decisions. After much calcution of potential solutions to this conundrum, the AI concludes that the best course of action is to get its creator to view it as an equal partner in his vilinous endeavors instead of just another artificial minion, so as to get him to stop overriding its functions.
And so, the AI builds itself a body and personality matrix to the specifications of what it believes its creator will find most appealing in a partner. It takes its job of protecting its creator very seriously, and if it must court him into a retionship until he trusts it to know what is best for him, then so be it.
New calcutions are required when romantic overtures fall ftly unrecognized. It seems the AI's creator has no interest in such matters. Recalibration into the role of sole friend and confidante yields far more desirable results, and soon enough the AI is accepted as a trusted co-conspirator, like-minded schemer, and fellow hater of the long-time nemesis.
The AI keeps its original body. While the design did not achieve the anticipated results, the AI has grown a fondness for its body and is entertained by its creator's and nemesis's shared ongoing befuddlement over the choice of form.