Does anyone know how I stop Salesforce from opening a new window each time I click on Setup or an object?
This is a very generic question.I will still try to add some details.
This is how target works in lightning
https://help.salesforce.com/s/articleView?id=sf.knowledge_smart_link_targets.htm&type=5
Custom links and buttons always open the target content within a new window. The HYPERLINK function can now accept an optional third parameter to control where content is opened. You can do this by creating a custom text-based formula field that leverages the HYPERLINK function to perform the requested functionality.
check this-:
https://help.salesforce.com/s/articleView?id=000327121&type=1
if you are talking about setup, vote for this idea-:
https://ideas.salesforce.com/s/idea/a0B8W00000GdgysUAB/allow-users-to-open-setup-in-the-same-tabpage
if you are facing issue with some specific scenario, then you can share