Why emacs commands work everywhere on macOS?
I can use emacs commands everywhere on macOS, which is good. But why? For example, in forms in Safari, I can use ctl-a, ctl-k, etc... I can use them in Note.app, too.
My guess is they are actually Unix commands and emacs borrowed them?
I can use emacs commands everywhere on macOS, which is good. But why?
Normally, asking “Why Apple does this, that, or the other thing” would be considered off topic, however, this one actually has an answer based in history.
The short answer to this is because the Emacs keybindings support is implemented in the Cocoa Text System.
My guess is they are actually Unix commands and emacs borrowed them?
They are not, however, Unix commands, because already pointed out in another answer, they are not found in the Unix specification. Also, they are not “universal” and cannot be used everywhere. They can only be used where the application(s) make use of the Cocoa Text System. For example, they cannot be used in Microsoft Word.
So, what does Cocoa have to do with anything? Well, Cocoa is derived from OpenStep which was a project developed by NeXT and Sun Microsystems to provide a NeXTSTEP like environment to non-NeXTSTEP operating systems. NeXT produced an OpenStep variation for its own Mach-based Unix.
Now remember, the macOS Unix kernel is Mach-based.
So, how did Apple get its hands on Mach and OpenStep? Well, on February 7, 1997 Apple acquired NeXT (along with Steve Jobs). The derivative products from that purchase was, you guessed it, macOS based on the Mach kernel, OpenStep, and all the other goodies NeXT had in their portfolio.
So, why did Apple bring over all those keybindings as they developed Cocoa? It only made sense for Apple bring over an environment developers (lots and lots of them from the Unix-verse) were already familiar with. Cocoa, derived from OpenStep, implemented the Emacs functionality already built into OpenStep.
Your guess is not really correct, no. These "commands" (or keyboard shortcuts) are not Unix-commands. The Unix specification does not say anything about system wide text editing short cuts or similar, so you cannot really say that it is borrowed from there.
I doubt that the answer from @ankii is correct either. It doesn't make sense that "for consistent design" you would have two different short cuts for each of many operations (such as for example Ctrl-A you mentioned having the probably more Mac-ish shortcut Cmd-LeftArrow).
Another thought could be that emacs actually borrowed these short cuts from macOS. This is not the case either. Emacs originated in 1976, while the first Macintosh System Software release is from 1984.
The most logical explanation would be that some or many macOS system programmers from an early time were users of editors with command short cuts similar to emacs (which would include emacs itself), or that a large enough subset of initial customers were such users - so they added on these extra short cuts for everyone to feel at home.
In fact some of these short cuts date back quite a lot. As far as I know, they originate with the "computer terminals" that were the way many large computer systems were accessed in the 1970s. In rough terms, terminals are the evolutionary step after "line printers" as the main interface, and before "bitmap displays" (computer monitors).
For example the popular VT100 series of virtual terminals (circa 1978) came with similar short cuts. For example similar to Control-K in macOS, Escape-K deleted to the end of line. Note that in those days, the ESC-key was not located on the keyboard where it is today.