I understand that you want to get y as a function of x, a and after that you want to using x=a condition and find a>20 at which diff(y) becomes 0.
For that limits of integral should be from 0 to x
y = simplify(int(expand(M*m),x , 0, x))/(E*I);
y = subs(y, x, a)
the above generated y is a piecewise function and if you set the condition that a>20, it comes down to single expression
f1 = diff(y,a);
eq1 = f1 ==0;
S = simplify(eq1);
a1 = solve(S,a);
a1 = vpa(a1)
From the code that you have mentioned in the comments, simplifying eq1 gives Symfalse as an output, which shows that there is no a >20 which satisfies the condition if you directly replace integral bound with 30.
S = simplify(eq1)