Usually, studies have a section about "methodology" where they address exactly this. Articles rarely quote this part. Most studies about the wage gap do in fact consider worked hours, different complements in payroll (like the ones for traveling), breakdown by sectors and occupations, etc. In fact, the wage gap is not the same across all occupations. Usually, the wage gap in the public sector is lower than in private companies and the higher you are the wider the gap, while the gap in lower categories is smaller. The gap increases the higher you go in your career. Hence the most famous cases are usually executives and high-paid workers. Unions can also decrease the wage gap, although "traditional" divisions of tasks might end in wage gaps too. For example, at a supermarket, cashiers are paid less than the people that fill the selves and once there, the managers usually put women as cashiers and men filling the selves even if those tasks can be done by either.
Many people don't consider the subtle things that affect payroll. This is intentional by HR, since they want to pay as little as possible. XD