When you first take a screenshot with the Automation Task, macOS asks if you want to give Alfred permission to record the screen. This is unavoidable, the Automation Task uses Apple’s own screencapture tool. If you refuse the permission, only the Desktop is saved in screenshots.
Go to System Settings → Privacy & Security → Screen & System Audio Recording, and enable Alfred there.