Well, as we were taught in kindergarten, it is wrong to assume that $\infty - \infty = 0$.
\begin{align}
p\langle p\vert\hat{x}\vert p\rangle - p\langle p\vert\hat{x}\vert p\rangle &= p\partial_p\delta (p-p)-p\partial_p\delta (p-p)\\
&= p\delta' (0)-p\delta'(0)\\
&= \infty - \infty
\end{align}
But, importantly, your second calculation is also mistaken. Notice that $\langle p\vert q\rangle=\delta(p-q)$ and thus, $\langle p\vert i\hbar\vert p\rangle=i\hbar\delta (0)\neq i\hbar$. Notice that this is perfectly expected because the identity operator is $\delta (p-q)$ not $\delta_{pq}$.
All of this "craziness" arises because the eigenstates of the position and the momentum operators are not normalizable. They are not in the Hilbert space, they only provide a useful basis for the states in the Hilbert space. A famous argument that closely relates to your first calculation is that $[\hat{x},\hat{p}]$ cannot be $i\hbar$ because we know that the trace of a commutator must vanish. This argument does not work because we cannot define trace for infinite-dimensional Hilbert spaces, or, as the learned like to say, the position and the momentum operators are not "trace-class". See Trace of a commutator is zero - but what about the commutator of $x$ and $p$?.