Raycast projects a ray (a line or line segment) from a point in 3d space. If that ray hits a collider, it returns information about what it collided with. It can be used for many applications, including the ones you have listed.
“why dont use vector3.distance” because you do not know what the thing is, or where the thing is. (if you know two points, sure, use distance.) but if you don’t know WHAT you are pointing to, you need to find out.
When (example) someone touches a screen, you DO NOT KNOW what is under the finger. this is how you find out. When your character looks out from behind a door, you DO NOT KNOW what direction he is pointing at, this is exactly how you find out. You see? it’s like A.I., the first step of A.I.
“enemy ai scripting” … yes you often use it in many ways for that
“we can use for shooting projectiles” … not usually, you just use “instantiation, and apply force on rigidbody”
BUT if you are shooting a “laser” or “instant” bullet (the bullet is not actually an object flying through the air, it just does damage in a straight line, you use a cast to calculate the impact point
“what is the scope” it can touch anything, or only certain “physics layers” of the scene - learn about physcis layers (very simple and powerful)