The code for the proof is
x, d = Reals('x d')
t = (simplify(simplify(((x + d)**2 - x**2)/d, som = True), mul_to_power=True))
print t
prove(Implies(d != 0, t == 2*x + d))
prove(Implies(d == 0, 2 * x + d == 2*x))
and the output is
(2·d·x + d2)/d
proved
proved
Please let me know if you know a more compact proof using Z3Py. Many thanks.