Take a very simple example.
A sales order is present in the system. User1 logs into the system and opens the sales order to do the certain updates. User2 belonging to a different department also has requirements to update sales order.
If these changes are dependent on each other, then user2 needs to know the latest updates made by user 1. If there is no locking concept there will be no way to know the updates made by each user.
Take the basic example trying to log into a SO thru VA02 when the same SO is opened by another user. You get the message stating the SO is locked by user XYZ. This is possible only due to locking.
When you open the SO using VA02, SAP creates a lock on the SO. This will make sure that only 1 user is allowed to update the SO at any given time. This will keep all updates consistent. Once user 1 performs a save or get out of the SO, SAP removes the lock so that other users in the system are allowed to work with the SO.
Adding lock to an object can be achieved using enquque and removing the locks are done via dequeue,
You can see the locks for any given user or on the system as a whole using the transaction SM12.
You can get lot more information on the same from SAP's documentation.
The SAP Lock Concept - ABAP Programming (BC-ABA) - SAP Library
V.