### Godot version

v4.1.rc1.official [1f9e540f1]

### System information

Windows 10

### Issue description

Attempting to reorder the children of a TabContainer results in an unintended ordering and incorrect undo states.

Also happens in v4.0.3.stable.official [5222a99f5].

https://github.com/godotengine/godot/assets/3820082/2c2458e3-88ad-46d9-8a04-f289a049984a



### Steps to reproduce

1. Add a new TabContainer
2. Add a few children to it
3. Drag and drop to erroneously reorder them
4. Attempt to undo the change

### Minimal reproduction project

N/A
for (int i = 0; i < instances.size(); i++) {
			memdelete(instances[i]);
		}
		return;
	}
	EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
	undo_redo->create_action(TTR("Instantiate Scene(s)"));
	for (int i = 0; i < instances.size(); i++) {
		Node *instantiated_scene = instances[i];
		undo_redo->add_do_method(parent, "add_child", instantiated_scene, true);
		if (p_pos >= 0) {
			undo_redo->add_do_method(parent, "move_child", instantiated_scene, p_pos + i);
		}
		undo_redo->add_do_method(instantiated_scene, "set_owner", edited_scene);
		undo_redo->add_do_method(editor_selection, "clear");
		undo_redo->add_do_method(editor_selection, "add_node", instantiated_scene);
		undo_redo->add_do_reference(instantiated_scene);
		undo_redo->add_undo_method(parent, "remove_child", instantiated_scene);
		String new_name = parent->validate_child_name(instantiated_scene);
		EditorDebuggerNode *ed = EditorDebuggerNode::get_singleton();
		undo_redo->add_do_method(ed, "live_debug_instantiate_node", edited_scene->get_path_to(parent), p_files[i], new_name);
		undo_redo->add_undo_method(ed, "live_debug_remove_node", NodePath(String(edited_scene->get_path_to(parent)).path_join(new_name)));
	}
	undo_redo->commit_action();
	_push_item(instances[instances.size() - 1]);
	for (int i = 0; i < instances.size(); i++) {
		emit_signal(SNAME("node_created"), instances[i]);
	}
}
void SceneTreeDock::_replace_with_branch_scene(const String &p_file, Node *base) {