We can enable the checkbox ‘ENABLE OPTIMISTIC LOCKING’ in the custom record for this restriction.
Enabling this option causes the system to check for conflicting updates whenever a user attempts to save updates to a custom record instance. If another user has saved updates to the same custom record instance while the first user was entering updates, an error is returned.