### Godot version

4.0.2 & 4.0.3 RC1

### System information

Windows 10, Vulkan API 1.3.224, NVIDIA RTX A2000 Laptop GPU

### Issue description

When saving a scene containing another recently saved instatiated scene with one or more resources being local to scene, Godot changes the affected Resource ID. This only happens if the Node containing the resource being local to scene is the root.
This Occurance is espacially problematic when working in a team with any source control solution.

### Steps to reproduce

- Create a new scene containing a MeshInstance3D node and make it the scene root.
- Assign a mesh and set the property resource_local_to_scene to true
- Create a second scene and instantiate the scene containing the MeshInstance3D node
- Without needing to change either scenes, save the MeshInstance3D scene (or any other instantiated child scene) first, then the scene where the MeshInstance3D scene is initiated


### Minimal reproduction project

[IdChange.zip](https://github.com/godotengine/godot/files/11380909/IdChange.zip)
In this example saving either child scene before the main scene will cause the error, but only the IDs of the Node labeled "ChanginIDs" will change.
Node *instantiate(GenEditState p_edit_state) const;
	Ref<SceneState> get_base_scene_state() const;
	void update_instance_resource(String p_path, Ref<PackedScene> p_packed_scene);
	
	int get_node_count() const;
	StringName get_node_type(int p_idx) const;
	StringName get_node_name(int p_idx) const;
	NodePath get_node_path(int p_idx, bool p_for_parent = false) const;
	NodePath get_node_owner_path(int p_idx) const;
	Ref<PackedScene> get_node_instance(int p_idx) const;
	String get_node_instance_placeholder(int p_idx) const;
	bool is_node_instance_placeholder(int p_idx) const;
	Vector<StringName> get_node_groups(int p_idx) const;
	int get_node_index(int p_idx) const;
	int get_node_property_count(int p_idx) const;
	StringName get_node_property_name(int p_idx, int p_prop) const;
	Variant get_node_property_value(int p_idx, int p_prop) const;
	Vector<String> get_node_deferred_nodepath_properties(int p_idx) const;
	int get_connection_count() const;
	NodePath get_connection_source(int p_idx) const;
	StringName get_connection_signal(int p_idx) const;
	NodePath get_connection_target(int p_idx) const;
	StringName get_connection_method(int p_idx) const;
	int get_connection_flags(int p_idx) const;
	int get_connection_unbinds(int p_idx) const;
	Array get_connection_binds(int p_idx) const;
	bool has_connection(const NodePath &p_node_from, const StringName &p_signal, const NodePath &p_node_to, const StringName &p_method, bool p_no_inheritance = false);
	Vector<NodePath> get_editable_instances() const;
	
	int add_name(const StringName &p_name);