Let me sketch how one can prove this identity. The identity can be rewritten as $$\sum_{\substack{|x|<p\\ 2|x}}\sum_{r|p^2-x^2}\left(\frac{-3}{r}\right)=p+2,$$ because for $x=0$ the inner sum is $1-1+1=1$. Writing $x=2c$, the identity becomes $$\sum_{|c|<p/2}\,\sum_{r|p^2-4c^2}\left(\frac{-3}{r}\right)=p+2.$$ The inner sum counts the number of integral representations $p^2-4c^2=a^2+ab+b^2$ divided by $6$, hence the identity is equivalent to the statement that the number of integral representations of $p^2$ by the quadratic form $a^2+ab+b^2+4c^2$ equals $6(p+2)$. The quadratic form $a^2+ab+b^2+4c^2$ has discriminant $12$, hence it is alone in its genus. So, by Siegel's mass formula, the number of representations can be calculated as a product of local densities. This is a mechanical task, since Siegel's original paper (Annals of Math. 1935) contains explicit formulae for all the local densities.