They're task runners (Gulp & Grunt, basically) - they themselves don't do much of anything.
They allow you to incorporate other tools - plugins - to accomplish a task before pushing to production.
So for example - you may want to minify your CSS and JS.
You'll build a script that takes in all of these files; runs a plugin against them to minify the css and js - that can output new files into a production path and then re-incorporate those files into html so the minified versions can be used and not the un-minified versions. You'll then push the production path to production.
Once the script is written, it's repeatable. Instead of doing all these things manually every time, once your ready to push, you'll run the script and verify the output.
The plugins can do a pretty wide range of tasks - remove console.log commands, obfuscate code, etc... You can of course, write your own plugins also.