So basically, ethereum is a state machine. You have a database of states (for example accounts with amounts). How these states change? by via of transactions. Which can be
give X ether from A to B to smart contracts invocations. OK, the transactions are grouped in a block. And here is where it gets interesting.
You have the universe of miners working on producing blocks. They take transactions from the pool, process them, until they reach the
gasLimit, assigning to their designated account (called the
etherbase) the transaction fees and the reward for block found in the end, and from here they produce a random nonce. The nonce is important: from this nonce and the block you made, you create a hash, complicated enough to make your machine work a lot (i.e. using a lot of CPU, memory and energy. That's why it's called Proof of work). Once the miner has a hash, this is compared to the target, which is no other than
2**256 / Difficulty, so the greater the difficulty, the lesser the odds of finding a hash lesser than the target.
Since you can produce randomly
2**256 possible hashes, from your block made and your nonce, your probability at any moment of finding a valid hash is
1/D. The first miner able to find a hash lesser than the target, propagates its result. If the other miners get this block, and find it valid (by replaying its transactions and verifying nonce and hash), it is incorporated in their respective blockchain.
Now, the question: How do they manage to reach about 14 seconds in average? Well, there is a difficulty calculation function (see this post for an outstanding explanation of it), that every time a block is made, is recalculated. Then, you see that based on what you take to produce the last block, you adjust the difficulty to be able to reach a time between
19 seconds. Of course this difficulty is validated along the new block too.
To answer your question, in the end, the
difficulty is related to data from the parent block, namely the difficulty, block number and time of this parent, and the time of the current block.