that is called a gallery when the corridor opens into a room on one side.
That's how it is (actually), but I think the question was really meant like this: why it is often called that today even when it is actually a simple hallway without any valley view into the ground floor. Simply because it sounds more valuable.