Sum of sample expectations of function of 2 variables (Understanding MMD)

The trick is to handle the diagonal elements ($i=j$) separately, which gives the $2mE_xk(x,x)$ part. The rest follows from this.