Every vertex has a 2D UV coordinate stored with it. This 2D coordinate maps to the part of the texture that corresponds to that vertex. In UV space, typically the lower left corner of the texture image maps to UV coordinate (0,0) and the upper right corner of the image is (1,1). You lay out the UV coordinates in the 3D modeling package used to create the model. It then just stretches the texture across each polygon based on the UV positions of each vertex associated with that polygon.