I don't know how I got this idea, sorry if it is already asked. I searched but couldn't find. Let's say there is a question and X person writes first answer with low quality. Then Y person comes and writes a good answer. Then, X answer edits his own question containing the information Y shared, sometimes exactly with same words. Is it possible to detect this? If it happens what should we do?
The proper response to this situation varies widely based on the circumstances and timing.
Your premised is based on the idea that "X" copied the answer from "Y" and added it to his post, But how do you know that happened? Word-for-word copying is obviously a good sign, but what if the wording isn't exact or isn't similar at all? How do you know that "Y" didn't arrive at the same idea that "X" did at the same time.
There is a phenomenon called Fastest Gun in the West (lovingly abbreviated FGITW) where users will post a quick answer to get in first, then add more to the answer as they go (often within the first 5 minutes so it doesn't even show up in the edit history).
But beyond that, users are known to post answers then realize they missed something or had another thought after hitting submit, and goes back to edit it in. They might not be aware of other answers that came in while they were typing.
This is where the timing of the events becomes important. If X and Y had answers at similar times or the "copied" info appears at a similar time, there is no way to know for certain that it was actually copied. It could have just been the aforementioned scenario. Now if hours have passed and this happens, then it is more likely.
In general, if you suspect someone copied your work, then you can flag, but keep in mind that multiple answers with the same/similar ideas and content are posted all of the time becasue there are only so many ways to accomplish a specific goal, especially for basic problems.
The other issue, as illustrated in the possible duplicate posts, is the CC-Wiki license of all content. I won't got into details since the possible duplicate already does a good job of explaining, but if the other user follows the attribution rules, then there is absolutely nothing wrong with it.
But most of all, regardless of what you decide to do with the post, following UV-D's advice, don't make a scene. That will just cause more issues and finger pointing, and then a mod will have to step in.