Marxism isn’t inherently opposed to hierarchy. Unlike anarchism, which often views hierarchy itself as unjust, Marxism focuses on unjust hierarchies rooted in exploitation and inequitable power over the means of production.
The core issue in Marxist analysis isn’t that the bourgeoisie and proletariat exist in a hierarchy, but that the bourgeoisie exploits the proletariat. The injustice lies in the relations of production, not in the structure.
Marxists can easily envision hierarchical structures that aren’t unjust like a workers' cooperative where managers are elected and accountable. These roles may be hierarchical in function, but not in power consolidation or exploitation.
The real divide here is between anarchist and Marxist ethics: anarchism sees hierarchy as the root problem, Marxism sees hierarchy as a tool that can be either just or unjust, depending on how power and labor are structured.