Changing prefab instances through script

I made a prefab gameObject with a rigidbody component attached. Whenever I change the mass of the original prefab from the inspector, all the instances present in the scene get affected (the field is not overridden). But when I try to do the same thing using a script, the mass of the instances remain unchanged (only the main prefab is affected and every time I enter play mode, it retains its previous value!).
The script is attached to another gameObject and looks like this:

  public class CubeScript : MonoBehaviour {
    
        public GameObject largeCube; // dragged the original prefab in the inspector
        private Rigidbody rb;
        // Use this for initialization
        void Start () 
        {
    
            rb = (Rigidbody) largeCube.GetComponent ("Rigidbody");
            rb.mass = 44; // this is not changing the instances, rather only the main prefab. Note that the mass is not overridden
    
        }
    
    }

I don’t understand as a beginner. The tutorials say that it is the same whether you change something from the inspector or using a script like that. Please explain this to me.

That is probably disabled at runtime on purpose to prevent unexpected behaviour.
As you just dragged the prefab in the inspector, largeCube references the saved prefab not an actual object in the scene.
If you want to change the instance’s value then you need to have a reference to an instance in the scene.
If you want to change all instance’s values, you should use a list or an array to reference all of your instance’s and iterate through them and change them one by one.