### Godot version

4.0 d93b66a

### System information

Windows 10 x64

### Issue description

I have a 2D scene with some 3D nodes. The root is node 2D, most nodes are 2D, I have 2D node selected. When I switch scene tab and back, the editor switches to 3D view, even though the 2D node is still selected.

I managed to strip the scene to bare minimum. You need a Node3D with Camera3D and DirectionalLight3D children.

https://user-images.githubusercontent.com/2223172/213327465-ba07760e-6dab-43c0-96e8-5109fcc0a576.mp4


### Steps to reproduce

1. Make 2D scene
2. Add some 3D
3. This bug has a chance to happen
4. Check the repro for setup that reproduces the issue

### Minimal reproduction project

[3DBug.tscn.txt](https://github.com/godotengine/godot/files/10452297/3DBug.tscn.txt)

Control *dock = dock_slot[dock_popup_selected_idx]->get_current_tab_control();
	ERR_FAIL_COND(!dock);
	Size2 borders = Size2(4, 4) * EDSCALE;
	
	Size2 dock_size = dock->get_size() + borders * 2;
	Point2 dock_screen_pos = dock->get_global_position() + get_tree()->get_root()->get_position() - borders;
	int dock_index = dock->get_index();
	dock_slot[dock_popup_selected_idx]->remove_child(dock);
	Window *window = memnew(Window);
	window->set_title(TTRGET(dock->get_name()));
	Panel *p = memnew(Panel);
	p->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("PanelForeground"), SNAME("EditorStyles")));
	p->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT);
	window->add_child(p);
	MarginContainer *margin = memnew(MarginContainer);
	margin->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT);
	margin->add_theme_constant_override("margin_right", borders.width);
	margin->add_theme_constant_override("margin_top", borders.height);
	margin->add_theme_constant_override("margin_left", borders.width);
	margin->add_theme_constant_override("margin_bottom", borders.height);
	window->add_child(margin);
	dock->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT);
	margin->add_child(dock);
	window->set_wrap_controls(true);
	window->set_size(dock_size);
	window->set_position(dock_screen_pos);
	window->set_transient(true);
	window->connect("close_requested", callable_mp(this, &EditorNode::_dock_floating_close_request).bind(dock));
	window->set_meta("dock_slot", dock_popup_selected_idx);
	window->set_meta("dock_index", dock_index);