I would like to take a stab at trying to answer this for you.
Please note that I am new at this thing too and trying to learn, but have done a bit of reading of late.
From what I can tell from my research they don't actually mine the individual coins as such. They are not "guessing" anything to do with the coin itself. What they have is a list of signed transactions.
To understand how it works you need to understand what a HASH is.
It's like a fingerprint of a big set of data. You can put the entire encyclopedia through a hash algorithm and it will give you a 64 character 'fingerprint' at the end. You can do this very quickly, but it is hard to reverse. You will find it very difficult to have a 64 character hash and reverse it to find out what data went into it to create it.
Also, if you change just ONE bit of the information the WHOLE hash changes. So you could put a full stop at the end of the encyclopedia and the whole hash would be different. You couldn't tell it was the same data + a full stop.
So with that in mind, this is how mining works.
The miner has a list of transactions, and a "nonce" which is a place he can adjust a random string of numbers and letters. He is also allowed to add his mining reward to the transaction list. So it looks something like this.
- Previous block HASH
- Miners address + reward
He keeps changing the nonce and running all the data through the hashing algorithm trying to find a hash that fits what is required. Depending on how quick the network is finding blocks the complexity increases. So he might be looking for a hash that starts with "000" or he might be looking for "0000000" at the start. The zeros increase/decrease depending how fast the network is finding blocks to try and keep them mining at 10 minute intervals.
Notice that the block also has to contain the hash of the previous block?
This makes it impossible to change any of the data on the block chain. You change one thing, even a full stop and the hash changes, which changes the next hash, and so on. It locks into the chain.
All of this takes sometime but once he has figured out the correct nonce and he posts it to the block chain all of the other nodes can QUICKLY check it but placing all the information he has given through the hash algorithm and check he has found the right solution. It's hard to arrive at, but quick to check for validity.
So once there is a transaction on the block chain that says your friend has received a coin from you the only way that is going to change is with a new transaction (your friend spends that coin). You cant go back and "re-mine" the block because it wont be accepted by the network. I mean you can "re-mine" it but unless your the spender, you cant sign the transaction with the private key that is linked to the wallet address and once you re-mine it, you'd then have to mine the next block and the next block and the next and so forth until your version of the block chain is longer than the version of the legitimate block-chain. Keep in mind that because the hash of the previous block is contained in the next block you cant just change what is there (see the rough explanation of hashing above) This is virtually impossible because your now competing against the network and they will win unless you have ore than 50% of the processing power at your disposal. Your block chain will never be accepted because "the longest chain" is always the one that is accepted by the network.
It really truelly is a beautiful thing.