My understanding of the double spending problem is as follows:
Suppose account A has 1 Bitcoin and sends it to account B and then creates another transaction which sends the same Bitcoin to account C. Some nodes may be notified about the first transaction first while other nodes may be notified of the second transaction first, leading to a conflict regarding which transaction actually occurred first and is the legitimate one.
If I understand correctly, mining solves this problem by forcing each miner to choose between one of the two transactions. But what happens if two miners receive two distinct transactions (A -> B vs. A -> C) and produce a hash at exactly the same time - won't each one still record a different sequence of events?
On a similar note, what happens if miners disagree about who produced the hash first? What happens if two nodes produce a hash at exactly the same moment? Some nodes will say miner x mined earlier others will disagree so how is this issue resolved? How does it end up that all nodes eventually agree unanimously and we don't constantly end up with different versions of the block chain?