For overwintering insects: a substitute for the shelter they evolved to use
The clearest documented case is the multicolored Asian lady beetle. In its native range, this species overwinters by aggregating in the cracks and crevices of rock cliff faces — a specific, narrow, stable microhabitat. North American buildings happen to offer an almost identical shape of shelter: narrow voids, stable temperature relative to the outdoors, and darkness. Research on the species' biology describes North American aggregation sites as concentrated in homes and other buildings, on warm upper stories and in wall voids specifically, which mirrors the rock-crevice pattern closely enough to be described as an analog habitat rather than a coincidence.
Cluster flies show a related pattern, concentrating in upper-story spaces and attics closely enough that "attic fly" is a widely used common name for the species. The pattern across these overwintering insects is consistent: they're not settling for whatever opening they find first, they're oriented toward a specific kind of cavity, and attics and wall voids happen to match it closely.

