The way it works is pretty simple. You enable a custom 404 handler in your web server (in apache, there is a ErrorDocument directive, see your web server docs if you use something else), and point it to a static HTML page. Here's mine: 404.html.
The Apache directive looks like this:
ErrorDocument 404 404.html
Google's code looks like this:
Now, should an old or incorrect link refer to you, the 404 handler will give them a search to find a better page. For example, there is no /carson link at my site, but here's what you get if you try: carson.
Takeaways? First, any self-respecting website should have custom error pages, even if they are static. Second, Google has a helpful utility that can help your site visitors find what they're looking for and it's a simple copy, paste, edit away from your site too.