Well 404 occurs in many ways like below:
You delete a page on your website and don't 301 redirect it
You change the name of a page on your site and don’t 301 redirect it
You have a typo in an internal link on you site, which links to a page that doesn’t exist
Someone else from another site links to you but has a typo in their link
If you are getting good links to a 404’d page, you be supposed to do 301 redirect it to the page the link was supposed to go to, or if that page has been removed then to a parallel or parent page. You do not have to 301 redirect all 404 pages. This can in fact slow down your site if you have way too many redirects.