Here’s another explanation to add to an old post, because I can and I find this example easier to understand.
When you receive a Pokémon, it has one of 3 ability slots, according to PKHEX.
Type 1 is for Wild encounters/Static encounters
Type 2 is for eggs and gift Pokémon
Type 3 is called the (H) Slot. This is reserved for a hidden ability.
For a Pokémon to get it’s hidden ability by breeding, one of the Parents must have type (H) ability. Even if the male Pokémon’s type 1 ability is the same as the females type (H) ability, it won’t be able to pass on hidden ability, due to having a type 1, not type (H) ability.