How can I go back to the previous location if the Editor takes me to another source or header file when, for example, I select the Open Declaration option?

Use the Alt+left shortcut key. This option is also listed under the Navigation menu.