I get that the legal ownership is not literally changing hands multiple times (mostly because of the comical inefficiency of the real estate market and the effect of transfer taxes).
As a seller, you agreed to price X. As a buyer, I contracted with you (the hypothetical you) to ensure you are paid X. I then do some legwork and find another buyer for X+P, and assign the contract to them. At closing, you get ~X; I get ~P; new buyer gets the property, and a bunch of do-littles in the process take a bunch of fees, expenses, taxes, and commissions off the table. I don't see the problem for you or I. You do and I acknowledge that.
You can feel free to insist (in the contract) that, under those circumstances, you are due X+P, and what you'll find is that the subset of the buyers who wish to assign the contract won't deal with you (you've taken their economic value add away), but you'll eventually sell the house. It might be for X - L, where L is the loss you take by excluding that subset of buyers, as remember that X was the highest offer you were able to find otherwise and that was from a buyer that you've now excluded. But at least you can feel good that you got the "full value" of the transaction.