File locking has a long tradition in computing: you or independently running software wants to make sure that a file isn’t modified or deleted when it’s needed or in use. Because macOS is Unix based, it offers file-level permissions flags that control how a file can be manipulated and by whom.
But macOS has long had a separate way to lock a file from the Finder that also prevents it from being modified, deleted, or rename from the Terminal or other apps. Lock, unlock, and status commands are also available via the command line in Terminal.
(Note that Finder-oriented locking is entirely different from setting a file to read-only permission either in the Finder or via the Terminal, which involves changing Unix permissions. I recommend not using read-only status for files and folder you work with in the Finder and via apps, as the Finder doesn’t honor those permissions for files that are assigned to you in macOS via Unix permissions, which typically includes everything in your home directory.)