Here are a range of PDF-manipulating command line tools that can be installed directly:
XPDF tools
https://www.xpdfreader.com/download.html
Coherent PDF tools
https://www.coherentpdf.com/usage-examples.html
You can of course use GhostScript to merge PDFs.
Binaries for Mac are here:
https://pages.uoregon.edu/koch/
If you're into python, there are various python libraries that will manipulate PDFs, such as pikePDF. https://github.com/pikepdf/pikepdf
I've also written a suite of python scripts that call macOS APIs to perform various PDF functions:
https://github.com/benwiggy/PDFsuite
(You'll need to install the pyobjc library.)