### 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
ERR_FAIL_COND_MSG(!p_node->is_inside_tree(), "_replace_node() can't be called on a node outside of tree. You might have called it twice.");
	Node *n = p_node;
	Node *newnode = p_by_node;
	if (p_keep_properties) {
		Node *default_oldnode = Object::cast_to<Node>(ClassDB::instantiate(n->get_class()));
		List<PropertyInfo> pinfo;
		n->get_property_list(&pinfo);
		for (const PropertyInfo &E : pinfo) {
			if (!(E.usage & PROPERTY_USAGE_STORAGE)) {
				continue;
			}
			if (default_oldnode->get(E.name) != n->get(E.name)) {
				newnode->set(E.name, n->get(E.name));
			}
		}
		memdelete(default_oldnode);
	}
	_push_item(nullptr);
	
	List<MethodInfo> sl;
	n->get_signal_list(&sl);
	for (const MethodInfo &E : sl) {
		List<Object::Connection> cl;
		n->get_signal_connection_list(E.name, &cl);
		for (const Object::Connection &c : cl) {
			if (!(c.flags & Object::CONNECT_PERSIST)) {
				continue;
			}
			newnode->connect(c.signal.get_name(), c.callable, Object::CONNECT_PERSIST);