Because they were told to and given the ability to. Remove the ability and instruction and they just spit out the next, most-probable tokens.
I don't understand the disconnect. People seem to think these things can just boot up, suit up, and start decimating systems. No. It's a loop. One initial instruction kicks off the loop and it will always be at the behest of a human (either directly or indirectly—indirect being they instructed the loop to write its own, post-kickoff prompts).
If that loop is given "tools" like the ability to perform shell commands, make HTTP requests, and the like and then given instructions to "do thing that involves using shell commands and making HTTP requests (at all costs)" then what the hell do we think it's going to do? Knit a "destroy all humans" Christmas sweater and present the head of Richard Simmons on a live stream?
"Computers do what you tell em' to. They don't all of a sudden start doing weird stuff. And if they do, it's probably your fault." - Brian Mettenbrink [1]