In this what does HIERARCHY and ATTRIBUTE do ?
"Hierarchy" defines the relationship between the various levels defined above.
In your example, Each Category can have multiple SubCategories, and each SubCategory can have multiple Products.
This also defines how the data aggregates to higher levels.
If your Fact table has a SalesAmount -
The SalesAmount for a given Category = Sum of SalesAmount for all child SubCategories.
Similarly,
The SalesAmount for a given SubCategoryCategory = Sum of SalesAmount for all child Products.
Attributes are the various characteristics or properties of the members at the levels defined.
Eg., Name, Min_Price etc. are properties of Product.