It's not just discipline. It's also partly how associative memories work (aka how the brain accesses memories). I have an office in my house that I can work from. It's a privilege to have this much space. But because I don't solely use the office for work its actually harder to focus while I'm in here. As soon as a task starts getting hard, my brain immediately goes, oh, you could play with this toy, or that toy, or do this other thing. Part of why I like to drive into the office is to have better control over the types of things I have access to, and to become conditioned to avoid certain types of distractions. That said, I've worked in openish offices, and found that to be a nightmare. So I'd take my office distractions over the distractions of a full on open office plan any day...
As a side note, it's not just spacial either. There's a body of evidence that shows time matters too for associative memories. Things like measuring test scores show that the brain is much better at testing in a given subject if the test is at the same time as the classwork. This also leads into other theories of learning, which suggest that if you really want to learn something well, do it in lots of different contexts at lots of different times so that you have a lot more neural paths to access said knowledge/ability.