If you close the 1st tab does it now work for the code in the other tab?
You should know that the PowerShell ISE is no longer a supported product. You'd do well to switch to something like VS Code or Visual Studio, or some other editor. Some folks like Notepad++.