B it is.
The below explanation might help.
The correct answer is B, thus containing two "hads":
The fact that King Alfred had occupied and fortified London in 886 did not mean that he had also won the loyalty of its citizens: the invading Danes were well aware of this weakness and used it to their advantage in 893.
Sequence of events:
886: King Alfred occupies and fortifies London and potentially wins the loyalty of citizens
893: Danes invade
Since 893 is in the simple past (Danes WERE), both events of 886, which is prior to 893, should be in the past perfect (HAD occupied, HAD won).