There are multiple ways to do it, but a good method would be to use signals and a function that frees the current scene.
If you have a collision for your flag (like an Area2D or something) you should be able to see its available signals in the "Node" tab on the right when the node is selected in the scene tree (or look up Area2D for the signal descriptions in the manual and find the one that matches best with your collision system).
You can unload the scene that you want to replace in this function (and it depends on how your game is designed). Let's assume you want to free your scene, named "Level1" which is attached to the root node (aka., it is the top-most node in your game) you might do something like this for your signal function:
# Queue the current scene to free on the next frame:
var root_node = get_tree().get_root()
var scene_node = root_node.get_node("Level1")
scene_node.queue_free()
# Load in some scene from our project files:
var new_scene_resource = load("res://Levels/Level2.tscn") # Load the new level from disk
var new_scene_node = new_scene_resource.instantiate() # Create an actual node of it for the game to use
root_node.add_child(new_scene_node) # Add to the tree so the level starts processing
And done. Now, that said, the SceneTree also has built-in 'change scene' functions which I assume do just as I did above in one function. I generally don't use them because I usually have some 'global nodes' inbetween the root and my actual level scene, but if you don't then it should be simpler in that you can just call:
get_tree().change_scene_to_file("res://Levels/Level2.tscn")