Ray-Sphere hit checking

I’m making a raytracer following this article.
There is a code of checking for ray-sphere intersection (page #11)
Could you explain next things:

  1. Why dot((p - c) ,(p - c)) = R*R. What does dot(a, a), i.e. between the same vectors do? So, if they’re the same vectors, then angle between them will be always 0 and cos(theta) will be always 1 and dot(a, a) will give squared length of vector a?
  2. I don’t understand how he’d made a quadratic equation at all