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.