It only destroys that copy. It shouldn't do much damage in the wild, since everything will have already been tested against it.
We're talking about risk scenarios. Of course there are positive uses for several dangerous technologies, but those who develop them should put thought into what would happen if they got loose in various ways.
Something that I don't think I've seen discussed here is the threat posed by an AI which is smarter than we are when it comes to computer security without being generally intelligent.
Suppose there were a computer virus that could read code, to the extent of looking at the programs on a computer, seeing how they process input from the internet, and how they could be exploited to run arbitrary code. Historically, viruses have been annoyances. How much smarter would a virus have to be in order to be a threat on the scale of say, a planetary EMP burst?