There is also the contract law, as long as it is an agreement reached by both parties through consultation. Moreover, there is an intermediary who has no interest to certify that the signed contract is valid. Both sides must abide by it. If there is a breach of contract, the court will support the contract.
As you said, both parties can sign the contract with Party A directly after canceling the contract. There's no need to go around in a big circle. But if it involves house demolition, it must be legally agreed with Party A. It doesn't matter if you bring others. I don't know if what I said can help you, but you'd better check and confirm some specific relevant laws and regulations! ! ! !