What are some reasons for sudden and sharp pains in one or both testicles?

Torsion. A sudden and sharp pain in the testicle is concerning for a testicular torsion, where the vas deferens (that carries semen from the testicle to outside) gets twisted, cutting off the blood supply. This is a surgical emergency as the testicle can be damaged and need to be removed. As a result, any sudden, sharp testicular pain should be evaluated right away. An er visit is reasonable.
Testicular pain. Testicular torsion, in which the vascular stalk supplying a testis is twisted, usually involves only one testis. It is a surgical emergency, for if not corrected, the testis dies & becomes non-functional. Other causes: inflammation/infection of the testis (orchitis) or the sperm storing structures (epididymitis) or both may require antibiotics. Trauma to the testes may lead to hematoma. See dr now.