In AngularJS, we call service any object registered in a module through the following functions: value, service, factory, provider.
A module can depend on other modules thus forming a hierarchy, but services defined into modules don't form a hierarchy and when the application is loaded they all go into a unique namespace. A service is visible (and available for Dependency Injection) to all the modules loaded in the same application independently of the modules hierarchy.
A service name can be used to register only a single service in the whole application.
Let's take a look at the modules dependencies in the example:
mainModule depends on childModule1 and childModule2 while childModule2 depends only on childModule3.
For each module we can see the names of the registered services and the same name provider1 is used by all the child modules to register different services.
The provider1 instance in childModule2 overrides the provider1 instance defined in childModule1 because both the modules are dependencies of mainModule and in the dependencies array childModule2 comes after childModule1. If the dependencies array was [childModule2, childModule1] then provider1 in childModule1 would override provider1 in childModule2. provider1 in childModule3 is overridden by the same definition in the other modules because the other modules are closer to the root of the hierarchy (they are children of mainModule, while childModule3 is a child of childModule2).