Being a sci-fi series, Bioware could
reconcile the endings by making some reference to multiverse theory. All of them are canon in one parallel universe or another, but ME4 happens to take place in one of the universes where ending X happened in ME3.
Granted, the series hasn't touched on the concept before, but when you think about it, the structure of the games seems to make the series ideally suited for it.
I know some theoretical physicist will say "that's not how multiverse theory works", to which I say, eh. It was good enough for Star Trek, it's good enough for Mass Effect.