You've been hard at work for lets say a year on your masters research and you then discover that someone else has been doing the same research as you have. (Let’s assume it’s a coincidence that the same research is done). What do you do in that case? Should you hurry and and get to the “winning line” ASAP? Should you or the other person change their research proposal?
Masters projects generally do not aim to produce top-quality original research, rather they give masters students an introduction in the art of doing research. So the fact that two people at two different institutes are doing more-or-less the same thing does not matter. It would only become a problem if
- One student plagiarized the work of the other.
- The two students collude, reducing their workload to produce one thesis that will be submitted twice.
- Both students tried to publish their work – whoever gets in first will receive the credit and the other will possibly not get published.
Even in the last case, it is not unheard of that parallel submissions of the same results by different parties occurs. Sometimes it is worth publishing both, especially if they approach the problem differently. I have heard of one case where the editors asked the two parties to produce a single combined paper.
Obviously, you should collaborate!
In your thesis itself, you need be careful to distinguish your contributions from your colleague's. But your thesis is a relatively unimportant administrative hurdle. Your short-term goal should be to work together on a common result that is stronger than what either of you could produce alone. Your long-term goal is to develop a network of collaborators. In the long run, that network will be worth far more than "winning" the "race".
You never did exactly the same work. Never.
The scenario you describe has happened to my Master's thesis as well as to many times later in my career. Typically you just feel as if they have done the same work but at closer inspection find differences in their approach as well as the research questions that they are addressing. The best thing to do in these cases is to revisit the narrative of your paper and emphasize the parts that make it unique. At masters level a good adviser will help you with that. If not, find some mentor elsewhere. Personally I find it helpful to show both pieces of work to a friend as they are much more likely to see these difference that I ever could. All this is actually simple psychology. After a year of working on your solution, everything looks like your solution to you. Which is also known as "if you have a hammer everything looks like a nail."
From a practical standpoint, you are a year into your masters, so you are likely close to being done. You need to decide if you need the publication. If you do buckle down, start writing, and find a journal with a fast turn around time. If not, it is no big deal, you can still submit your thesis.
Before moving forward on an academic career, and maybe any other career, I would suggest stepping back and considering your communication and networking strategies. Getting scooped (or even racing to publish) is a communication and networking failure. Basically, you need to understand why you and your advisor did not know this other research was going on.