In my own country the border guard is part of the military- its a special form of military police. They also protect embassies for some reason.
Trust me the US does not have a patent on bureaucracy... Over the centuries things just develop. One can only assume it made sense once.