I don’t believe that the “name” attribute being used as an identifier is the unspoken intention of the specification. The attribute’s name “name” does already provide a hint for the attribute semantics - “names” are usually not unique and multiple things can go by the same name, yet be different things.
It would also not occur reasonable to me to “merge” layers with the same name. If they have different visibility or style, then which do you keep and which discard? Which do you apply? What about a round trip, do you throw away information? (Ok, this last one does not matter for a read-only implementation such as a viewer.) But for these reason I would keep both layers and show them as they are (with the same name). A user or software can fix this if they like.
The question is rather: How did the two layers with same name get in there and should it be illegal? I would speculate that this results from a merge and find it perfectly reasonable to keep both layers. I think (speculative again) merges could actually have been the reason for the schema authors to model it this way. Of course we could have namespaces with unique names prescribed in the schema, but then during a merge the same-name-layers would have to be renamed (not merged), I believe. Would that win us anything? And is the price acceptable?