There are two errors possible in APEX about concurrency:
- EXCEPTION_THROWN System.QueryException: Record Currently Unavailable: The record you are attempting to edit, or one of its related records, is currently being modified by another user. Please try again.
- FATAL_ERROR System.DmlException: Update failed. FIrst exception on row 0 with id ............; first error: UNABLE_TO_LOCK_ROW, unable to obtain exclusive access to this record: 
If two users try to update an account at once, when the second user tries to save the data, the error message in your question will be displayed in the Salesforce user interface.
When the second user tries to update the account, the system detects that the account has been updated by another user since the edit session began and blocks the update. Salesforce is using a type of record locking approach called optimistic record locking which is not at the database level.
This concurrency locking only applies to different users. If you have two asynchronous or external service calls running in the same user context and a concurrency issue comes up, it will not be detected.
That might explain why you couldn't replicate the issue with code.