*Here is a perspective from (pure) mathematics.*

It is not that unusual in mathematics that a problem is solved (almost) simultaneously by two different people, one of whom will sometimes be a PhD student. Generally, both papers end up being published, and are treated as independent discovery; later on the student can include it in their thesis. This makes sense, especially since the ideas involved in both works will usually be different so both are useful to the community. (Publishing new proofs of old results is also not unheard of, but usually carries much less prestige, presumably a bit like replication studies elsewhere.) In borderline cases, the students tend to be treated slightly more leniently than established researchers, since it is understood that publications matter more to them (it may or may not help they have a supervisor who is often a well-respected researcher).

It should also be pointed out that PhD students will generally not embark upon projects which take many years to complete, so the window for simultaneous discovery is much shorter. Even if one tries to attack a big problem which takes a lot of time and effort, if any progress is being made then interesting results will appear in the process and hopefully be published (if this is not the case, it would be doubtful if the big theorem is likely to be proved at all).