According to Arfken et al. Mathematical Methods p.277 $$[x,p^2]=xp^2 - pxp + pxp -p^2x =[x,p]p + p[x,p]= 2ip \, .$$ According to the text this follows solely from $[x,p]=i$.
I'm not understanding how the squared operator is being applied.
How is the commutator on squared operators supposed to work to get the middle terms $pxp$? Why would it not be $[x,p]p - p[x,p]$.