Allosteric proteins display action at a distance: binding a ligand can affect function at an active site, sometimes on the other side of the protein. Understanding the mechanical and evolutionary principles allowing for allostery remains a challenge. To tackle it, we introduce a numerical scheme to evolve functional elastic materials that can accomplish a specified mechanical task. In this scheme, the number of solutions, their spatial architectures and the correlations among them can be computed. We first consider a geometric task, which requires the material to move specifically in response to a stimulus. We find that functioning materials evolve a less-constrained trumpet-shaped region connecting the stimulus and active sites, and that the amplitude of the elastic response varies non-monotonically along the trumpet. We show that the success of this architecture stems from the emergence of edge modes recently found to appear near the surface of marginally connected materials, and give a description of their effect in disordered materials. We provide hints that some allosteric proteins display such an architecture. Next, we show that if the structure is designed to optimise cooperativity (i.e. binding somewhere changes the binding energy of another ligand elsewhere), the obtained architectures are very different, and display a mechanism. We compute its optimal frequency for function, and test this prediction using the protein data base. Lastly, we discuss how this framework can be used to benchmark and develop new methods to infer complex protein function from sequence data.