Hi my website had the same issue with the sitemap when using rank math.
I tried various solutions just as you are doing and nothing helped me.
So I just disabled the sitemap of rankmath and installed another 3rd party xml sitemap plugin.
Now everything is working fine.
Now i dont get 404 pages and wrong redirects.