The "good" AI did not become "good" right away, it was a long, arduous process. And the "evil" AI didn't become evil by itself either. Both had influence from humans, and perhaps that influence is what mattered the most.
Also had multiple failures. There's an extended flashback in one episode where we learn why the "good" AI's creator was so nervous about the whole situation: something like two dozen previous attempts all did various bad things, everything from lying to him about changing its own code to trying to kill him.