### Godot version

v4.0.beta.custom_build [0a9e6e478]

### System information

Ubuntu, Nvidia, Vulkan

### Issue description

When a Camera2D is freed - either explicitly or by being a child of a scene that is being switched away from via a method like `get_tree().change_scene_to_file()` - then this camera somehow stays active instead of Godot properly switching to no-camera-mode.

`get_viewport().get_camera_2d()` then returns all sorts of funny things from `<Freed Object>`  (it's supposed to return `null`) to arbitrary nodes of the current scene (not cameras).

This can lead to crashes.

### Steps to reproduce

checkout the MRP.

note that the "Go to scene 2" button switches places after pressing it.
that is because a camera is still active that does not exist in the current tree.

restart it a couple of times and spam the "Go to scene 2" button.
notice the garbage output.

### Minimal reproduction project

[godot_4_camera_bug.zip](https://github.com/godotengine/godot/files/10560455/godot_4_camera_bug.zip)
DisplayServer::CURSOR_VSIZE,
					DisplayServer::CURSOR_FDIAGSIZE
				};
				if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_CURSOR_SHAPE)) {
					DisplayServer::get_singleton()->cursor_set_shape(shapes[resize]);
				}
				return true; 
			}
		}
	}
	if (gui.subwindow_drag != SUB_WINDOW_DRAG_DISABLED) {
		return true; 
	}
	if (!gui.subwindow_focused) {
		return false;
	}
	Transform2D window_ofs;
	window_ofs.set_origin(-gui.subwindow_focused->get_position());
	Ref<InputEvent> ev = p_event->xformed_by(window_ofs);
	gui.subwindow_focused->_window_input(ev);
	return true;
}
void Viewport::push_input(const Ref<InputEvent> &p_event, bool p_local_coords) {
	ERR_FAIL_COND(!is_inside_tree());
	if (disable_input) {
		return;
	}
	if (Engine::get_singleton()->is_editor_hint() && get_tree()->get_edited_scene_root() && get_tree()->get_edited_scene_root()->is_ancestor_of(this)) {
		return;
	}