There is no hierarchy. This is a misundrestanding of the Scrum Guide, which I explain in more detail below. However, you should note that the Product Owner is a distinct role from that of a Developer. The Product Owner role does not share the same accountabilities as the Developers, other than that of collaborating with the other roles defined within the framework to ensure the overall success of the Scrum Team and the project.
Analysis and Recommendations
[Is the] Product Owner also supposed to do development and testing? If not, then obviously there is a hierarchy in a Scrum team[.]
This is fundamentally incorrect ab initio. The mistake appears to be that you're conflating the fact that the 2020 Scrum Guide explicitly states:
Within a Scrum Team, there are no sub-teams or hierarchies. It is a cohesive unit of professionals focused on one objective at a time, the Product Goal...Scrum Teams are cross-functional, meaning the members have all the skills necessary to create value each Sprint.
Somehow, you are coming away from that statement to the conclusion that all members of the Scrum Team are fungible. This is said nowhere in the Guide, and isn't even considered a reasonable practice. People are not widgets, and they can't be swapped for one another as if they were all identical.
There are three distinct roles defined for the Scrum Team within the Scrum Guide: the Scrum Master, the Product Owner, and the Developers. The role of Developer has a different set of accountabilities than that of the Product Owner, so while the Product Owner and Developers must collaborate, there is absolutely nothing in the Scrum Guide or the field of practice to suggest that the cross-functionality of the team requires that non-Developer roles (or even individual Developers) must be interchangeable in terms of skill sets, experience, or process responsibilities.
That said, the best Product Owners usually have enough technical skill to collaborate successfully with the Developers to ensure that the team as a whole is able to define, plan, craft, and deliver Product Increments successfully. While a Product Owner is properly focused on what the project should deliver, and the Developers are focused on how to deliver it, if they can't successfully communicate with one another it is ultimately the Scrum Master's job to facilitate better communication or to help the team resolve this foundational problem.