What can be done if one's research paper is rejected by some journal and same research paper is published by other researchers in different journal?
It also happened to me. This shows that different researchers, reviewers & editors have different viewpoints on the same research paper i.e. one man's trash is another man's treasure. If our research paper is rejected, don't give up - what we can do is keeps improving & submitting until it is accepted by a journal.
Han Ping Fung Yoy said correctly. I have also different opinion on this. Who will take the guarantee from reviewers that research paper which that are rejecting will not be leaked by them to others. This can never be simply coincidence that the same idea is hitting in the mind of different researchers and gets published in next one or two months after rejection.
While this is very unfortunate, this can happen in various circumstances. While this is not a solution to your current situation, one can help prevent such occurrences by uploading pre-prints to arXiv, ResearchGate, personal websites, etc. In such a situation, one could at least claim to have attempted to publish the idea at an earlier time.
This is still not a complete solution, as researchers may potentially have similar ideas without ever seeing the other's work, but it can at least help guarantee that you receive (some) credit for the original ideas. Moreover, if you have proof that you published the data online (in it's pre-submission format), then you may be able to help resolve your current situation.