I know very well how it is resolved, the question is why the double spend appear in first place.
To start with, stop calling it a double-spend. It's not double spend until it's in the blockchain, it's double-spend attempts. And double spend is not possible.