tl;dr — JS works out where to put the value before working out what that value is, and a side effect of working out what that value is changes the value of a.
See the spec for simple assignment.
Step 1 is "Let lref be the result of evaluating LeftHandSideExpression."
Step 2 is "Let rref be the result of evaluating AssignmentExpression."
So the first thing that happens is that a property x is created on the object stored in a (where n is 1).
Then the right hand side is evaluated (which ends up overwriting a with a new object where n is 2).
Then the result of that expression (that object where n is 2) is assigned to x on the original object (where n is 1).
You can see this in effect with:
"use strict";
var a = {n: 1};
var b = a;
a.x = a = {n: 2};
console.log(a);
console.log(b);