This question has nothing to do with sharing sensitive data between two companies.
The question is really whether Company A's contract with you obligates you or the hiring company to pay a commission when Company B gets you the job.
This depends pretty much entirely on the terms of Company A and Company B's contracts with you and with the hiring company.
If the contract with Company A entitled it to a commission if you get hired, regardless of how that comes about, then they are entitled to a commission.
In real estate, it is common place that the entire commission goes to the only real estate agent on the deal if there is just one, and is split evenly between two real estate agents if there is both a real estate agent for the seller and a real estate agent for the buy involved.
In the U.S. real estate market, this arrangement on commission sharing is not something that is dictated by law and is instead enforced by the rules of a professional association that controls the multiple listing service for real estate and is joined by almost everyone in the industry. Usually that professional association mandates that disputes between members over commissions from the same sale be resolved by the association's mediators.
Now, your question concerns Germany and concerns headhunters, rather than real estate agents. But, I wouldn't be at all surprised, particularly given the way that Germany deals with many similar issues in its economy, to find that there is an association of headhunters which everyone who participated in that activity must join (or usually does join) and that commission disputes are resolved by arbitration through the association of that dispute.
We don't know from your question, who Company A and Company B have contracts with and what the terms of those contracts are, so it isn't possible to answer that question knowing only what we do.
There is certainly nothing wrong or improper about Company B using its personal connections to cause an employment applicant to get a job with a hiring company on a paid basis. This is what headhunters are in the business of doing. And, there is nothing inherently unfair about one company getting business that a competitor in the same industry tried to get, in the absence of some sort of contractual prohibition applicable to the prospective employee or the hiring employer. The only question is who should be entitled to what commission and we don't know enough to answer that question given the information that the question provides.