I am convinced that in office software teams produce more and better code overall than remote ones do. I am remote now and go to my office about a week every two months, and those weeks tend to be ones I can rally the team to get big initiatives done. I put in the same effort when I'm remote but it just doesn't work out the same. You can blame tooling, you can blame the company not being remote-first or remote-forward or whatever, but I honestly believe the reason there are so many champions for remote work is simply because people want to do it and it's easier or more comfortable for them.
I don't disagree with that. My current office people keep about 6 hour workdays, including their lunch break. We're also multi-national so overlap is usually where shit gets done. I have many days where the bulk of my productivity comes in 1 hour of a call with a Portuguese or American engineer. (I'm in Iceland).
That might sound like a case for being remote, but for me, it's usually been much more effective in the office because that single hour of overlap was most of the day. Yes, some of it is wasted time, but I did and still do build great working and personal relationships with my peers in that "wasted" time that I still cherish.
Counterpoint: pre-Covid I had an in-office job, and I would specifically request a WFH day if I had an especially meaty problem to write. The office was full of distractions, whereas at home I could focus in on writing code without background noise. Several of my coworkers followed the same pattern.
That's more of a respect for your coworkers thing than a remote vs. office thing though?
Headphones on meant leave me alone in every shop I've been to. I also, personally, rarely have extended periods of just coding. The value I add is almost exclusively helping other people work through problems at this stage in my career. "Distractions" are "the job" for many of us.