If the validation works, please move to the second point.
2. Have you verified the correct version of your website on Google? Please check if you have verified the www (or non-www) and https (or http) version of your website. If there is a mismatch, please fix that.
3. Finally, make sure you have cleared the cache and excluded Google bot from seeing a cached version of your sitemap.
If you have followed these and you are able to view your sitemap without any problem, then Rank Math is outputting your sitemap correctly and the error must be coming from Google. You can try and use a 3rd party sitemap plugin to confirm. Just make sure you have disabled the Sitemap module of Rank Math in WordPress Dashboard > Rank Math > Dashboard when using a 3rd party sitemap plugin.