What if someone else published an article on the same topic as my accepted unpublished article
After a journal has accepted an article, they're ethically bound to publish it unless there's an egregious error or abuse on the author's part. Some examples could be:


They discover that you actually submitted your paper without acknowledging a critical person who contributed so much to the work that she should have been a co-author;
They discover that you plagiarized significant sections of your paper;
They discover that the reviewer they invited for the paper was actually you, using another name.


In your case, the journal will need to show that you must have known about the other paper before you submitted yours. If they can do this, then you are acting unethically, and they can retract your paper. If they cannot, then they'll go ahead and publish, and you can claim to have discovered the result first while the other authors discovered it independently.