Barring a medical condition that required a very specific diet, I would never, ever feed a dog nothing but dog food.
Would any human eat nothing but Total cereal (or a similar very highly processed food) and assume it's a healthy diet? No! And yet the dog food manufacturers have worked very hard, and have had a lot of success, at convincing a gullible public that feeding their pets nothing but highly processed, dehydrated crunchy bits is healthy.
The flip side of that is that not all "people" food is good for pets. A lot of it isn't good for humans! You have to educate yourself and use some basic common sense.
Unfortunately, too many people don't bother to educate themselves and/or lack the common sense gene, and so to err on the side of caution a lot of vets will advise not feeding any "people food" to pets. Not because there's anything wrong with it when done right, but because so many people just don't bother to do it right.
Spaghetti is probably not a good choice for a dog. Neither are the remnants of a cheesy, greasy casserole with a zillion ingredients.
But a little hard boiled egg, plain yogurt, some steamed veggies, a bit of leftover lean grilled chicken or steak w/o sauce? Absolutely!
Now I've got to go fix my dogs some breakfast. For which they'll get a bit of dog food and a few spoonfuls of green beans. I cook a pot every week just for them. And no, neither of them needs to lose weight. They just love green beans.