I used to live in an area with lots of apartment buildings and had to babysit a friends dog for a couple of weeks. I met a couple of people when I took the dog out at 6:30am because they were doing the same thing. Ran into the same people every day. Plus you always let the dogs visit (sniff each other) so starting a conversation is almost automatic.
Now I have my own dogs. Easy to meet people if you go to obedience, agility, or other dog classes.
With a dog you get all of the above, plus the affection from the dog, plus the additional exercise.
I've had the same experience. There are regulars that I get to talk to most days, and many of them have interesting stories. I'm friends with a retired college professor, lawyer, political activist, journalist, nurse, wedding planner and restaurant manager, fitness instructor. All from hanging out at the same dog park almost every day for a few years now. It only takes 30 minutes a day and makes me feel less lonely.
Dogs are a pain in the ass. They smell bad, and make your home smell bad. They require constant attention. Leaving them at home, locked up, all day long while you're at work working long hours is cruel. Your apartment/condo will require you to pay a big fee to get their poop DNA tested, and when you don't pick up their poop, you'll be slapped with a huge fine. Honestly, it's easier having a child: at least children can go to the bathroom by themselves after a few years, and eventually can feed themselves too.