Blockchain is a consensus based system. A transaction in the bitcoin blockchain is only valid when it has 6 block confirmations, meaning the block which contains your transaction is 6 blocks deep in the blockchain. Even your wallet containing X amount of coin is only on the mutual consensus of the nodes present in network.
Blockchain logically is a single chain which is shared across multiple participating nodes.
Thus, action of branching out of new chain from the pre-existing chain at any given point of time is called a fork.
Analogous to git where once can create new branches from present working branch.
Based on conditions fork of a blockchain can be of two types:
But sometimes, when there is a sudden flaw occurs in the system due to external attack or internal bugs, then the entire participating nodes gives consent to fix the flaw, for which a hard fork takes place from the point of time in the past where the system was working fine. e.g. DAO attack in the Ethereum blockchain, which resulted in the creation of Ethereum classic.
Fork has is adverse affects too, called fork attack. Where a attacker node in the network can create his own forked chained and claim for his false transactions, given the fact that he can only claim his transaction if the attack controls 51% for the nodes in the network. As he has to gain 51% consensus to make his chain a valid chain, as other pure nodes will disagree to it.
Hope it explains to some extent. :)