How do RPG manage scenes?

What I want to learn about is how scene management works.

For example:

1) when the player enters an area for the first time, a cutscene triggers. If the player enters the same area again, there is no cutscene.

2) sometimes, you have to talk to a character to progress the story. Talking to this character will ‘teleport’ you to a different area and the game continues from there.

3) depending on what point of the game you are in, some areas might be locked. Playing the game further will unlock these areas.

We can have 100s of boolean flags and “if else” checks to achieve this, but the code would get really messy. How can we manage scenes in a clean way?