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.