(It's difficult to know what to hide as a spoiler and what not to, I've done my best to hide what I think counts as spoilers but if it seems inconsistent or non-sensical, let me know.)
As explained by Legion, mostly in Mass Effect 2, the geth are "software", and form a consensus on how they should act.
In Mass Effect 3, you encounter Legion on the Geth Dreadnought. Despite fighting your way through geth, Legion is friendly. After freeing Legion, it helps you escape, even though other geth are trying to kill you.
I don't understand why Legion is pursuing a different course of action to the other geth.
It makes sense in Mass Effect 2 why the geth you fight against would act different to Legion as they left the geth consensus to "follow the Old Machines", so they are now effectively two people, two kinds of geth, two separate consensuses.
But in Mass Effect 3, those "other kind of geth" are either destroyed or rewritten as per Legion's loyalty mission in Mass Effect 2, so there is only one kind of geth at this point. Legion is therefore presumably the same kind of geth as those fighting you, so why would it work against them?
According to the fandom page about Legion (emphasis mine):
it houses 1,183 geth programs, as opposed to the roughly one hundred found in other platforms, enabling it to operate independently and speak.
Is it that Legion is effectively its own consensus, capable of acting separately to the greater geth consensus? Doesn't this contradict the implication from Mass Effect 2 that it is part of the consensus who chose not to follow the "Old Machines"?
Legion even claims that it was a "difficult decision to make" to ally with the "Old Machines" when you meet him in Mass Effect 3, implying that it is part of the geth consensus, but then helps you anyway.
Can someone explain (ideally with evidence from the trilogy, be it quotes from the games or from BioWare staff or whatever) why it makes sense that Legion, who as far as I am aware is part of the one-and-only geth consensus during the events of Mass Effect 3, would act differently to the rest of them?
(I'll point out that, at time of writing this, I haven't yet done the next missions after the Geth Dreadnought mission, so they might provide additional context; it's been a while since I last played through this game...)