Some 404 errors cannot be prevented, say if a user mis-types a URL, but in a lot of cases they can be avoided easily. Especially if you are migrating from an old site to a new one, your URL's will change. When users do not update their bookmarks they end up on the old non-existing URL. Also the Google index will take a while to update, and it will keep on sending users from the search results to your old URL's. This can heavily impact your search rankings!
The way to go is to determine what your old URL's are, and to reroute them to the new ones. This should be done through a so-called 301-redirect. Such a redirect is accompanied by a permanent-moved-code. This lets Google and other search engines know that the old link should not be used anymore, and also informs them of the new URL. If you are lazy, you could choose to let all links automatically end up on the homepage. Then you have at least informed Google that they have been redirected, but you may loose all rankings built up for the specific pages. better is to reroute the links on a page by page basis.
For a small site this can easily be fixed. Make sure you still know what your old URL's were, and then just enter this URL. Or you just wait one or two days untill users will have hit these pages. These pages will now be registered in your Joomla site: Go to Components -> Redirect and you will see them in the Redirect Manager:
Opening any specific item will allow you to enter the new URL and activate the record.
If you are very anxious about your current search rankings, if you do not want your visitors to see the 404-errors, or if if you have a really big site, you need to be prepared for this.
First, you should again determine all URL's of the old site. Then, determine the corresponding new URL's. Now you need to implement the 301 reroute for all these URL's. You can either enter these in the Redirect Manager manually, or use an extension (ReDJ is a nice one).
Also it might be just as easy to do this in an .htaccess file, especially for large sites:
RewriteRule ^oldpage1$ "http://newsite.com/newpage1" [R=301,L]
RewriteRule ^oldpage2$ "http://newsite.com/newpage2" [R=301,L]