The basic point (as pointed out by Kev, above), is that the namespace URI is the important part of the namespace, rather than the namespace prefix, the prefix is an “arbitrary convenience”
As for why you need a namespace manager, rather than there being some magic that works it out using the document, I can think of two reasons.
Reason 1
If it were permitted to only add namespace declarations to the documentElement, as in your examples, it would indeed be trivial for selectSingleNode to just use whatever is defined.
However, you can define namespace prefixes on any element in a document, and namespace prefixes are not uniquely bound to any given namespace in a document. Consider the following example
<w xmlns:a="mynamespace">
<a:x>
<y xmlns:a="myOthernamespace">
<z xmlns="mynamespace">
<b:z xmlns:b="mynamespace">
<z xmlns="myOthernamespace">
<b:z xmlns:b="myOthernamespace">
</y>
</a:x>
</w>
In this example, what would you want //z
, //a:z
and //b:z
to return? How, without some kind of external namespace manager, would you express that?
Reason 2
It allows you to reuse the same XPath expression for any equivalent document, without needing to know anything about the namespace prefixes in use.
myXPathExpression = "//z:y"
doc1.selectSingleNode(myXPathExpression);
doc2.selectSingleNode(myXPathExpression);
doc1:
<x>
<z:y xmlns:z="mynamespace" />
</x>
doc2:
<x xmlns"mynamespace">
<y>
</x>
In order to achieve this latter goal without a namespace manager, you would have to inspect each document, building a custom XPath expression for each one.