I've toured a bunch of apartment buildings in a major city and the nicer ones often had people using the communal study areas, game rooms, lounges, fitness centers, and roof decks.
Obviously there's a cost to provide that and it's one many are willing to pay.
I've visited many expensive buildings in SF and lived in several. Those buildings do have study areas and lounges. But those places are never cozy and never designed to help people interact. They are often in a separate area or floor, away from the main entrance. The lounge areas are separated for multiple groups to use without interfering with each other. Furniture is heavy, expensive, and hideous. Tables are heavy or unmovable. There are no coffee tables. Music blares.
Architecture & design that fosters community will have a space for eating and socializing near the main entrance. When you enter or or exit the building, you can see who is there and walk over to say hello. The space will be cozy, clean, with warm lighting, good ventilation, movable chairs & tables, and no music or TV. There will be a sink with hand soap & paper towels, a microwave oven, and a hot water kettle. And a clean toilet around the corner.
I would be willing to pay for that, but so far no company has had the imagination to offer it. There's a similar lack of hot-desk co-working spaces that are suitable for coding. I would love to pay for that, too, but it doesn't exist. I've spoken with many co-working space managers and none have shown interest in making it happen.
Supporting your point, in many hotels the bar/restaurant area is visible from the lobby, which naturally invites people it to have a drink or a bite to eat. But its rare to find this architecture in apartment buildings.
This is why I loved an old Victorian-era house I once lived in, which had been converted into four apartment units. We all shared the large, deep wraparound front porch, and thus we'd occasionally gather for drinks. And neighbors would drop by, too. I miss that place.
Obviously there's a cost to provide that and it's one many are willing to pay.