Why is this grammar ambiguous?
Rici is correct.  The statement could be reasonably interpreted, as you first assumed:

if E then ( if E then x ) else x


It may also be interpreted:

if E then ( if E then x else x )


In a context-free grammar, the allowable set of expressions are determined through substitution.  In the first interpretation I took your third statement and substituted the first S for the second statement, and then replaced all remain S with x.  In the second interpretation, I took your second statement and replaced it with the third statement, and replaced the remaining S with x using the first statement.