For consistent data, when a record is being created or updated, it is locked so that other users cannot update the record.
FOR UPDATE keyword in SOQL helps us to lock the records from being updating from another request. Sample Code – https://www.infallibletechie.com/2015/05/how-to-lock-records-using-apex-in.html
Locking Issue may happen due to Skewing issue – https://www.infallibletechie.com/2019/11/salesforce-data-skew.html
Salesforce Reference Link – https://help.salesforce.com/articleView?id=000338933&type=1&mode=1