As with most things, this depends on the dog. Elderly dogs, like elderly humans, often need to pee more often and want to drink more often too. This often means they need to urinate more often, and when they are not given an opportunity to do so, they may urinate in the house, or sometimes even in their sleep without realising it. For an elderly dog who has been house trained all their life, this can be quite distressing, to wake in a wet bed, as it would be for a human being. It can also result in skin problems.
Some owners withhold water to prevent this sort of problem happening so the dog can be left longer without wetting in the house.
I fostered an elderly rescue dog who had this issue, and the advice of my vet was that withholding water was both inhumane and could result in further health problems arising. In particular, dogs that are taking heart medication will need to pee regularly. This is because medication such as furosemide is designed to prevent fluid buildup by moving it through the body.
However, younger dogs can often hold their bladders for what seems like a very long time. My own saluki cross (aged 7) has currently been for about 18 hours without urinating. The door is wide open to the garden, and she could go out there if she wants, but it's been raining all day and she hates the wet. She seems to be able to sleep quite happily for a very long time without needing a pee break.
Some breeds of dog are better at this than others. Sighthounds have a reputation for being able to sleep uninterrupted for a long time, but the Italian Greyhound, one of the smallest, is supposed to be very difficult to house train, perhaps because of the small bladder size, and will need more regular breaks than a typical ex-racing greyhound would do.
It's probably a good rule of thumb that dogs should be given regular pee breaks unless it's clear they don't need them, and that owners should be aware that this sort of need may change as a dog gets older.