Here's what I know about Alfonso of Castile and Juana la Beltraneja. It's an odd situation and I would take the view that their betrothal was very much political and might well have been agreed to by the cortes on the basis that Juana was not Alfonso's niece anyway.
Enrique IV was the only son of King Juan II by his first marriage. He married twice but was apparently unable to consummate either marriage, being known to contemporaries as Enrique ‘the Impotent’. Attempts were made at artificial insemination via a specially-made brass tube, but it was generally assumed that the daughter born to Enrique’s second wife in 1462 was fathered by Don Beltran de la Cueva, who was rumoured to be the lover of both king and queen. The cortes refused to accede to Enrique’s request that they accept the infant Juana ‘la Beltraneja’ as his heir, and in 1463 he recognised his nine-year-old half-brother, Alfonso, as heir, on the proviso that he married la Beltraneja. In 1465 a noble faction led by the king’s chief minister, the Marques de Vilena, persuaded an assembly to declare Enrique deposed and installed Alfonso as king in his place. On Alfonso’s death in 1468 amid rumours of poison, the nobles put Isabella, Enrique's half-sister, and whole-blood sister to Alfonso, forward as a potential ruler. Under terms agreed with Enrique, Isabella was recognised as queen and married to Ferdinand, the heir to Aragon, who was the nearest male heir to Castile, though the marriage treaty provided that he was to take second place in the government of Castile behind Isabella. Enrique retired into seclusion for the rest of his life, but the settlement was not universally accepted, since Alfonso V of Portugal championed the cause of la Beltraneja, and war continued until 1479, when la Beltraneja was consigned to a convent.
Ann