Traditional flag etiquette prescribes that before an American flag is stored or presented, its handlers should twice fold it in half lengthwise; then (from the end opposite the blue field) make a triangular fold, continuing to fold it in triangles until the other end is reached. This makes a triangular "pillow" of the flag with only the blue starred field showing on the outside, and it takes thirteen folds to produce: two lengthwise folds and eleven triangular ones.
The American flag isn't folded in this manner because the thirteen folds correspond to the original thirteen states, or because the folding produces a shape resembling a cocked hat, or because each of the folds has a special symbolic meaning. The flag is folded this way simply because it provides a dignified ceremonial touch that distinguishes folding a flag from folding an ordinary object such as a bed sheet, and because it results a visually pleasing, easy-to-handle shape. That this process requires thirteen folds is coincidental, not the product of design.
An even more elaborate flag folding ceremony has since been devised for special occasions such as Memorial Day and Veterans Day, one which incorporates the association of particular symbolic meanings with each fold of the flag. These associations are "real" in the sense that they mean something to the people who participate in the ceremony, but they are not the reason why a flag is folded in the traditional thirteen-step manner.