Question: When you hit  `⌘ command` + `T` in Xcode it will open new tab, but in the last position.

How can I change this behavior to be able to open new tab just next to the current active tab?

Answer: 
I haven't come across anywhere or found an answer myself for this. The logical explanation for Xcode opening the current file in a new tab and not the next file would be that Xcode cannot figure out what file you wish to open in the new tab, though in the navigator you may see the files are one below another, but it is up to you to open whichever file you want and Xcode let's you be the judge of that. Perhaps Xcode could just open a new empty tab but instead of that it opens a new tab with the same file and let's you choose which file you want to pick.

OR

There is one more option but it ain't `Cmd + T`. You can select the file you want to open in the new tab holding (don't let go) `Option + Shift` and then when a dialogue opens, you can click the **+** mark on the top right of that window.

OR

You could set the **Double-click Navigation** (Xcode -> Preferences -> Navigation) to **Uses Separate Window Tab** (Uses Separate Tab in Xcode <12).
Go to Xcode Preferences -> Navigation -> Navigation Style -> Open in Place.