This is known as the Anya Paradox (more formally known as the Spy x Family Paradox). This is an un-explainable event that happens once every thousand years. The infinite loop of Anyas happens only in the anime, not the manga. Science is close to finding to the answer to this paradox, yet no one has found the reason.