Every page should have a canonical tag. Don't wait for google being smart => It is not.
(A canonical tag prevent from negative seo by injecting parameter)
Here if you have multiple links to the former version (without www) google has multiple reason to think that the previous url is the right one.
So your solution is to provide a self canonical for the ...
In Rank Math, you can set the canonical URL on a page-by-page basis. In /wp-admin/ go to either a Page or Post -> Edit Page/Post -> scroll down to RankMath SEO -> click the Advanced tab.
Add the canonical URL of your choice in the field like so:
RankMath, by default, tries to automagically set canonicals for post/pages. Hopefully, that overrides ...