i had this experience as well that often the wrong container was picked.
but maybe i am using the wrong workflow
When I need to open a GitHub tab for my organization admin account, I open a new tab in my "work/admin" container first, then nav to GitHub. Child tabs are opened in the same container. This is 99% of my usage.
Following an incidental link from elsewhere to GitHub will open in the default account/primary container (or "no container"). Or, you can right-click and select "Open in New Container Tab > Container X" if you are aware of the need to switch accounts ahead of time...(and if you are not, there's "Reopen in Container > Container X").
I don't use the multiple-windows/multiple-containers model. There might be an extension for "open all tabs in this window in container X" though.
I use Profiles and multiple windows when the separation is important, and Containers in the same window when the separation is merely convenient.
this is also a problem with using multiple profiles in different windows
I use Firefox container tabs (for GitHub specifically) instead. It's lighter-weight and the UI is better. Container tabs are color-coded, so the different accounts are easy to distinguish.
Or you could use container tabs in multiple Firefox windows under a single Firefox profile.