If you know what caused the 404 error and you can fix the link that caused it, it’s best to do that. This will be the best indication of quality of your site for both users and search engines. If not, you should try to redirect those faulty URLs to the right pages, by creating them manually in your .htaccess or your NGINX server configuration or creating them with a redirect plugin.