It was (is) a real thing that archtitects have thought about. In 1969, the concept was named arcology. I learned about them through SimCity 2000 which helped popularize the concept.
I think, culturally, it's an offshoot of Modernist thought. One trend in modernism is that science can be used to find more efficient ways to live, and that science will lead to human dominion over all natural processes. Some thinkers took this to one (terrible) conclusion and wondered about if people could live, work, and socialize all within one building; one efficient and contained (and human controlled) space.
Real skyscrapers were often designed with this in mind, and we still see the echoes of it today with concepts for Mars colonies and hanging-building mega-cities in Tokyo.