Rings whose elements satisfy quadratic equations