Is it normal for components added by script at runtime STAY in the editor?

I just discovered that component scripts that get added to prefabs during RUNTIME, are actually staying attached to the prefab even when I am back in editor mode. I have prefabs now with multiple copies of a script component since a new one got added every time I tested the game!

Is this normal behaviour? I would have expected that anything added at runtime would be “temporary” and automatically destroyed when the game is stopped.

I’m trying to find further information on this (no luck so far, hence this question).

Changed made to Assets in the Project folder is permanent. To avoid this you should only make changes to the instance of the asset and not the asset itself.

Permanent change to a prefab asset:

    public GameObject prefab;

    void Start()
    {
        // Add an Animator component to the prefab Asset
        // This is a permanent change
        prefab.AddComponent<Animator>();
    }

Runtime only:

    public GameObject prefab;

    void Start()
    {
        // Create a clone of the prefab
        var instance = Instantiate(prefab);
        // Add an Animator component to the clone
        instance.AddComponent<Animator>();
    }