It is different for different cultures but also depends on mobility.
In western world it is currently family but that's because family ties are much more likely to be preserved over time than ties to your village.
In other places in the world people are so immobile that they are expected to be born, grow up, work and die in the same village. And so ties to your local community are much more likely to be preserved over time just like ties to your family. It is not that the village replaces your family, it is just another group of people where it makes sense to invest to get something back in the future. Imagine you had tight knit group of friends where you left school but somehow are still able to stick together. If you trusted that this will continue for a long time it would be much easier to invest within the group knowing somebody might help you out later.