If you use Width = 50%x, it sets the width to half the screen width.
And where is it horizontally positioned ?
The left edge remains where it is.
Lets take an example:
You set, in the Designer, a width of 40%x, the anchor to RIGHT and the right edge aligned with the right edge of the screen.
This means that the Left position or edge is at 60%x and the right edge at 100%x.
Then when you set the width, in the Designer Script, to 50%x.
The Left position remains where it is at 60%x but the right edge moves to 60%x + 50%x = 110%x, therfore 10% out of the screen.