Emergence of division of labor in tissues through cell interactions and spatial cues