Thanks.
But what incentivizes miners to mine on the longest fork?
The longest* fork has the greatest chance of remaining the longest fork. All other forks will be orphaned and any generated coins on orphaned forks are worthless. It is in a miners self interest to avoid worthless coins and that means always building off the longest fork. Thus when miners learn that another block has been found which extends the primary chain they will switch and build off of that. Doing anything else means a reduction in income.
* Longest technically means the most work not necessarily the most blocks as Bitcoin selects as the primary chain the one with the highest collective difficulty.