If you get a link from a teams document library and send it via email to other users, then when they click on it it takes them to the online version of teams but not to the document. Once the online teams window has loaded in the browser and you click on the link again from your email then it takes you to the document in another tab!
I do not think this is a "bug". The reason can be that you are not "authenticated" to Teams before You have logged on to/opened teams. You can try by first open the online version of teams and then click the link to the document to see if the behavior is the same.