Masters Student in Math: Picking an Advisor
If nothing is set in stone yet, it would be reasonably to explore the possibility of switching advisor.

However, I don't think it's necessary. You are not expected to be doing exactly the same thing for a masters as a doctorate. Or indeed, even anything massively close. Within the UK at least, many doctoral students will come through the MMath rather than a stand-alone masters, and in theory may not have done any sizeable project. My project was completely unrelated to my thesis topic.

Indeed, personally I would suggest not switching topic. The way you are describing things, the topics are close enough that having the additional breadth will actually help your doctorate. You should develop an understanding of material around your thesis topic, not just the exact question you study.

But also do start talking to the potential doctoral adviser, and start to get a feel for whether the two of you are happy to work closely together.