I'm starting to believe this theory: In order to be more concentrated, just go work to a coffeeshop. When you sit down to work in a coffeeshop, a whole set of habits kicks in. Here are a few things that make working in a coffeeshop special.
Isolation from people
When you're in the office, you automatically have other people around you to talk to. When you go working to a coffee shop, you go alone. You don't talk to anybody, there is no one to talk to. A big distraction is eliminated.
No food or drinks
When working from home, the fridge is always in the reach. In office, there are always some snacks. In a coffeeshop, you can order something, but I rarely do so. Somehow the coffeeshop food doesn't tempt me, so I stick with just coffee.
No standing desks
I have a standing desk and I must admit that it can be distracting. Sometimes I change position every 30 minutes. Sometimes I get tired while standing - and then I think about being tired. Changing position is often similar distraction as grabbing something from the fridge or making a tea.
No wonder they say "sit down and do your work". There is really something special about "sitting down". When you sit down you know you're going to be focused. When you stand up, it's not always the case.
There are no other physical distractions - there is no "other place to sit", no couch, no bar - just one seat and one desk.
When I go work to a coffeeshop, I order a coffee and something to drink and then I sit quietly for 2 hours. I don't go to bathroom, I don't go for a walk, I don't go eat anything. I have this strong coffeeshop habit: 2 hours of coding.
It's just like 45 minute school classes. School taught us to sit in one spot for 45 minutes. We spent many hours learning this habit. I have a similiar habit for coding in a coffeeshop - 2 hours of work at a time. I don't question it.
Headphones chain you to your desk. Somehow, this helps me not even think about getting up. The cord reminds me I'm supposed to sit in one place and not go anywhere.
Second, good headphones can mute every sound around you. That creates a strong effect of isolation. For me it's an Avatar-like experience of entering another world. Headphones with strong sound isolation make this effect stronger. Right now I'm using Shure SE 215. They have these foam tips so they act like earplugs, making the effect even stronger.
The coffeeshop habit
I have created a coffeeshop habit for myself. Anytime I open my laptop in a coffeeshop, I automatically switch to high-focus mode. It became a strong habit over the years, and now it helps me overcome times when I can't concentrate - I just go into a coffeeshop.