\Zend\Mvc\Application::init() creates the service manager, passing in a ServiceManagerConfig, which by default defines a few factories.
So in a typical \Zend\Mvc\Application, the module manager get wired into the ServiceManager via that factory. The factory is responsible for creating the ModuleManager the first time it's requested.