You seem to have fallen into the common error of believing that the prefix is the important part of the namespace. It isn't. The namespace URI is what defines the namespace, and the prefix is just a meaningless
string for the convenience of XML authors.
In the first example you have a "{http://www.example1.org/xml/sample}category" attribute and then you have a "{http://www.example2.org/xml/sample}category" attribute. These have different names.
In the second example you have two "{http://www.example.org/xml/sample}category" attributes. They have the same name.
And in the third example you also have two "{http://www.example.org/xml/sample}category" attributes, which have the same name.