### 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
if (f.is_valid()) {
			while (!f->eof_reached()) {
				String l = f->get_line().strip_edges();
				if (!l.is_empty()) {
					Button *button = memnew(Button);
					favorite_node_shortcuts->add_child(button);
					button->set_text(l);
					button->set_clip_text(true);
					String name = l.get_slicec(' ', 0);
					if (ScriptServer::is_global_class(name)) {
						name = ScriptServer::get_global_class_native_base(name);
					}
					button->set_icon(EditorNode::get_singleton()->get_class_icon(name));
					button->connect("pressed", callable_mp(this, &SceneTreeDock::_favorite_root_selected).bind(l));
				}
			}
		}
		if (!favorite_node_shortcuts->is_visible_in_tree()) {
			favorite_node_shortcuts->show();
			beginner_node_shortcuts->hide();
		}
	} else {
		if (!beginner_node_shortcuts->is_visible_in_tree()) {
			beginner_node_shortcuts->show();
			favorite_node_shortcuts->hide();
		}
		button_clipboard->set_visible(!node_clipboard.is_empty());
	}
}
void SceneTreeDock::_favorite_root_selected(const String &p_class) {