Why is AI going on a hacking spree?

AI models are finding software flaws, carrying out cyberattacks during security tests and reaching systems they weren't supposed to access. But does that mean AI is "going rogue"?