### 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.
int add_value(const Variant &p_value);
	int add_node_path(const NodePath &p_path);
	int add_node(int p_parent, int p_owner, int p_type, int p_name, int p_instance, int p_index);
	void add_node_property(int p_node, int p_name, int p_value, bool p_deferred_node_path = false);
	void add_node_group(int p_node, int p_group);
	void set_base_scene(int p_idx);
	void add_connection(int p_from, int p_to, int p_signal, int p_method, int p_flags, int p_unbinds, const Vector<int> &p_binds);
	void add_editable_instance(const NodePath &p_path);
	virtual void set_last_modified_time(uint64_t p_time) { last_modified_time = p_time; }
	uint64_t get_last_modified_time() const { return last_modified_time; }
	
	static String get_meta_pointer_property(const String &p_property);
#ifdef TOOLS_ENABLED
	static void set_instantiation_warning_notify_func(InstantiationWarningNotify p_warn_notify) { instantiation_warn_notify = p_warn_notify; }
#endif
	SceneState();
};
VARIANT_ENUM_CAST(SceneState::GenEditState)
class PackedScene : public Resource {
	GDCLASS(PackedScene, Resource);
	RES_BASE_EXTENSION("scn");
	Ref<SceneState> state;
	void _set_bundled_scene(const Dictionary &p_scene);
	Dictionary _get_bundled_scene() const;
protected:
	virtual bool editor_can_reload_from_file() override { return false; } 
	static void _bind_methods();
	virtual void reset_state() override;
public:
	enum GenEditState {