The leading underscore on MacOS is part of the Mach-O standard [1]. This was inherited from a.out which really wasn't much of a standard per se but rather just a collection of a.out implementations [2]. Mach-O (1987) predated ELF (1993) and the later ELF abandoned the underscore as unnecessary.
It actually doesn't prefix all symbol names as such! The underscore prefix indicates the cdecl calling convention specifically; other calling conventions have their own name mangling schemes.
Edit: I had a nagging feeling that I was forgetting something, and I was. This is only a Windows convention, not a more universal thing.
You'll find this on Linux, too. You'll notice the compiler (on POSIX systems?) prefixes your symbol names with _ since The Dawn Of Time.