Some people who aren’t productive at home can’t fathom that others might be. When they say “people slack off when they work from home” they’re really saying “I slack off when I work from home”.They are working, what makes you think they aren’t?
Personally, I prefer being in an office with other people, but I can totally understand that there are people who don’t work as well in that environment.