There are many reasons for the Yoast wordpress SEO plugin xml sitemap throwing 404 error. It’s a simple fix. If whatever the options given at SEO -> xml sitemaps don’t exist or never created, then probably it will throw 404 error (Page not found) when you open xml sitemap.
Just check (select) pages and Media in exclude post types (if they are not checked), save and reopen xml sitemap. It works.
If not, check (select) other settings in exclude post types or Exclude taxonomies, save and reopen.
You will see xml sitemap working without any 404 error.