How can one handle age discrepancy between a local clique and self?
For background, this is well pre-COVID-19 situation, so it does not include the pandemic as a factor.
Around two years ago, I worked as a software developer. Most of the work took place in a small office, with frequent chit chat, jokes and active work-related talk.
There was tight teamwork going on, from which I was excluded - or at least it felt so to me. I came to blame my age: I was 29 (visibly older, receding hair) at the time while everyone else was in their early 20s, and also the team was entirely male.
I tried to take part in chat around the coffee machine, tried to sit at their table during lunch break, initiate smalltalk, and even started vaping (which is popular here) to have a common mini-hobby. But everything felt artificial, and they were overly polite when talking to me, as if I was 50+, avoided referring to me during work, often to the detriment of team performance, but especially my productivity. I was treated as a friendly old man, but not as an full-fledged insider. There was respect, but huge distance in familiarity.
Eventually I switched to academia for two years, within the same company, but because of unfortunate reasons I have to switch back to my old job after the pandemic ends. How can I prevent this situation from reoccurring?