if you set change an collision or area in code, you need to use call_deferred or set_deferred which just means that the function will be called at the end of the frame or something like that (next idle moment).
the syntax is set_deferred("propertyName", value) or call_deferred("functionName", "functionParamater - optional")
Changing collision information in the middle of the frame messes with the physics that happens that frame