You are wondering how to best deal with A's problem, but you need to realize that this is not primarily A's problem but yours.
Why? You are "running a lab". That means science. Now in your lab, a problem met a solution. That is the best thing that can happen in science. But it sells itself as a problem to you.
You want this to happen, and you want to encourage that to happen. Of course, you should try to wrap your head around what you can do in future to make this happen sooner rather than later. That's a long-term strategy. Part of it is making sure that you are up to date on the state of art at a name-dropping level so that you can offer suggestions to your post-docs what material to get acquainted with to be sure they are not obsoleted by prior or ongoing work (and if there is ongoing work, try maintaining the contacts to have a good idea whether there is a way to join it while it happens).
The problem you now have is to sell to A that they have likely wasted time and work regarding the goal of making science progress. It would not be honest to try burying B's work or rather discovery, and you need to figure out what B feels they should be getting out of it: they way you relate this, it seems like they are quite aware about the difference in actual invested work compared to what A did and are comparatively flexible regarding how to on from here.
Now it very much depends on A's priorities how to best serve their interest. Essentially there are the options:
a) need to get something published, no matter what. That is likely best served by finishing what they started. If turning the method found by B into a formal and tested and verified paper on the same problem space takes longer than finishing A's work, there is not even a conflict. It's just that A's paper is doomed to early obsolescence, but that would be independent of whether B is involved with applying the published third-party method to this particular problem or not.
b) need to establish lasting credits particular to that topic. In that case it is essential for A to get up to speed with B's discovery and publish/copublish about it in a reasonable time frame. Whether this is better served by first publishing work, methology and verification of his current approach and then basing a second work on this, or by binning his current work and restarting (and trying to secure funding, deadlines etc for it which you should support to the utmost of your ability) immediately is A's decision.
Being able to run a serious in-depth analysis of "best prior art competently applied" to "new method" is very very valuable for advancing the state of science and B cannot deliver that because he does not have the 2-year experience of A.
So again: this is a stroke of luck for science, and it is the thing what running a lab is for. It is your task to make both A and B see this as the stroke of luck it is and make sure that it turns into a net positive for both of them in order to make the progress of science line up with the well-being of your post-docs. Since this will involve replanning (particularly for A) and throwing large pieces of one's scientific fortune into an unplanned pairing with a colleague, it is your task to ensure a solid and trustworthy basis for the collaboration of the two. How much time and effort you will need to invest yourself very much depends on the two's ability to progress to coordination where both are satisfied with the outcome. Particularly regarding the actual workload and involvement and payback of B, there is a wide range of what can feel satisfactory to them, more so than with A, given their upfront work.
If they have problems trusting one another, it is your job to provide a common point of trust by nailing down agreements and making clear what developments you are willing to accept or not in the course of work submitted under the auspices of your lab.
Good luck in making this work! It's rare to get a chance to actively align the interests of people and scientific progress, and you should do your best not to waste it.