Technically, at that time kings were decided upon by the Witenagemot (assembly). We're not sure how pro-forma that typically was, but this was the accepted way a new King gained their legitimacy as ruler.
No man can make himself king, but the people has the choice to choose
as king whom they please; but after he is consecrated as king, he then
has dominion over the people, and they cannot shake his yoke off their
necks.
(Ælfric of Eynsham, 10th Century)
This means there was a certain elective element in the position, and thus at the absolute least, an ability to select someone else in the royal family if the dictates of strict primogeniture would have selected someone less suited for some reason.
In the particular case of you mentioned, there had been an agreement (compromise?) made during a previous Witenagemot that Alfred the Great's brother would become King, with Alfred his successor. This dully happened, but when Alfred died, this naturally led to it being debatable who should be next; the children of Alfred or of his brother.
In April 871 King Æthelred died and Alfred succeeded to the throne of
Wessex and the burden of its defence, even though Æthelred left two
under-age sons, Æthelhelm and Æthelwold. This was in accordance with
the agreement that Æthelred and Alfred had made earlier that year in
an assembly at "Swinbeorg". The brothers had agreed that whichever of
them outlived the other would inherit the personal property that King
Æthelwulf had left jointly to his sons in his will. The deceased's
sons would receive only whatever property and riches their father had
settled upon them, and whatever additional lands their uncle had
acquired. The unstated premise was that the surviving brother would be
king.
Perhaps the "original sin" in all of this was King Æthelwulf leaving everything to his sons jointly, rather than the typical medieval custom of leaving everything to the eldest. That basically left a succession time-bomb where everyone in that generation technically had equal claim to the throne. A Witenagemot settled it, but only by putting the crisis off to the next generation.