If a sailing boat is tacking or if the people in it tack it, it is sailing towards a particular point in a series of sideways movements rather than in a straight line.
If you tack pieces of material together, you sew them together with big, loose stitches in order to hold them firmly or check that they fit, before sewing them properly.