When Jesus began to cast unclean spirits out of a man, they asked Jesus to send them into a herd of swine, and Mark wrote,
And at once Jesus gave them permission. Then the unclean spirits went out and entered the swine (there were about two thousand); and the herd ran violently down the steep place into the sea, and drowned in the sea (Mark 5:13).
Unclean spirits are able to do anything because the Lord has granted them permission, even as He did when Satan sought to harm Job, and the Lord allowed Satan to do somethings to Job, but the Lord also put restrictions on what Satan could do.
The Lord does not do the evil, but He allows evil some rein, which gives us a choice to serve the Lord or to serve evil.