Search engines have two major functions: crawling and building an index, and providing search users with a ranked list of the websites they've determined are the most relevant.
Search engines finds the sites when the user submits its sitemap.xml to Webmaster tool for indexing websites or webpages, then the web crawler visits and crawls the websites and saves it in its database and caches it which is very important in SEO.