attributes only return the attributes of the element. To query tags in a PHP DOM object, you need to use getElementsByTagName or getElementsByTagNameNS available in PHP DOM. Or use PHP XPath (https://www.php.net/manual/en/domxpath.query.php).
Please note that this is not a phpdocx question but a PHP DOM question. We recommend you read more information on the PHP DOM documentation (https://www.php.net/manual/en/book.dom.php).