I think you misunderstand how C# reference types work.
(Edit: actually the logic is the same whether it’s a reference type or not.)
in this case:
mat = GetComponent<Renderer>().material;
mat is a reference variable pointing to the Renderer’s material. using mat, LumoKvin could have set any of the properties (i.e. color, mainTexture whatever) and it would have updated the renderer, because mat and GetComponent().material are both referencing the exact same material.
That’s not what LumoKvin did, though. Instead, he assigned mat to reference a different material, by typing mat = newMaterial;
At that point, mat is no longer referencing the renderer’s material, it is referencing a completely different material that has nothing to do with the render. So once you assign mat to a different material, it would not make any sense for it to update the render’s material.