Obviously, school or day care makes it simple: they're not around, no problem.
Nanny and in-laws work pretty well too. They leave me alone unless they really need something.
My wife sometimes intrudes. She currently works as well, and typically works one day a week from home. She's a bit lax on those days, and she can forget that I'm not going to be the same way. I accept this when I can, and shut it down firmly but kindly when I can't.
The older kid has been coming straight home from school for the past year, no after-school care. It was harder to get her to understand that she can't monopolize my time until I'm done with work, but we got there.
The key is to set clear boundaries and expectations. Physical reminders help. Your office needs to have a door and you need to feel free to close it to keep people out. How much you need to do this will depend on how you work. I tend to deal with interruptions fairly well, so I mostly close my door for meetings and calls, but sometimes it's good to do it just to be able to concentrate. I reinforced this with a sign on the door saying "When is it OK to interrupt my meeting?" listing things like medical emergencies, fires, floods, aliens, etc.
Be kind, but be firm. Although you may be home, you are at work. As long as everyone understands this and respects it, you'll do fine.
Edit: forgot to mention, the boundaries and expectations need to go both ways. When you’re not at work then you’re not working. Don’t drag your laptop out or wander back to your office in the evenings. Make exceptions in unusual circumstances if needed, but the routine should be a clean separation both ways. Not only is this a good idea for your mental health and family wellbeing, it will make it easier to remember and respect your work time too.
Prior to having children of toddler age (as in, children able to physically bang on my locked office door), working from home was the only time I was able to maintain deep focus and accomplish difficult tasks.
My wife does an amazing job keeping my 3 children happy and occupied, but the noise and distraction level at times creates an atmosphere worse than being in the office. I have come to the realization that this is just a temporary phase that will pass. In a few years, once the kids are in school M-F 8~3, WFH glory will one day return. In the meantime, I've discovered quiet places in the office to hide out and perform deep thinking / heads down work. If I was paid more $$, I suppose I'd probably rent a temporary or shared space to periodically work from.
Just because I could give my employer more output doesn't mean I should. Especially if I'm already doing plenty to not draw any criticism.
Having an office with a door that closes is key.
Having my wife run interference on the kids is key wouldn’t happen if she didn’t play ball.
With those two factors I’ve worked remotely for a dozen years (only the last five with kids).
Working in the office is better that way, but given the choice I think I’d rent a private spot at the nearest co-working space (right now my company does not allow remote work).