The collider property is probably declared like that in Component :
public Collider collider{ get{ return GetComponent< Collider >(); } }
That’s why you can directly affect an other collider to it. To achieve that, you need to destroy the current collider if there is one, then add a new one.