This situation is by no means "hypothetical". If you are not alone to be interested in the range of problems you are working on, it is pretty much
guaranteed to happen to you sooner or later.
The answer to the question as posted is "on a case by case basis". No general rule applies and no universal attitude exists. You can meet everything from bitter rivalry, fight for priority, and open hostility between the "groups" (or individuals) in question to a gentleman's argument of the kind "you go ahead and publish now and I'll hold my opus for a while".
The simplest and easiest to handle case is when the proofs run on drastically different ideas and employ nearly disjoint sets of techniques. Then one may, of course, try to squawk that he was there a few days earlier but everybody understands that the real test is whose approach turns out more viable and useful on the long run (and quite often they both survive, just lead to different developments). There is no question about the possibility to publish each of them either.
The worst case scenario is when the proofs are nearly identical or one is obviously superior to another, so once you see one paper, there is no reason to look at another one anymore. If the authors know each other and are on friendly terms, they can usually figure out some reasonable strategy (combining everything into one article under all names is the most common way out). Otherwise pretty much anything can happen.
Most situations are somewhere in between. So, just apply your common sense, remember that good relationships are more beneficial on the long run than establishing priority, don't think that you (or anybody else) may really own a mathematical statement or its proof any more than one can own the wind or the light or that one can carry any "credit" beyond the grave, enjoy other people successes as your own, and you'll be totally fine.
If the question is just about "how to cite properly?", when in doubt, cite both works and abstain from any judgement about priority, etc.