Why headphones get tangled if headphones are in a pocket? I wonder if there is some mathematical reason that explains why always headphones cords are tangled if they are in a pocket. Thanks in advance.
 A: Yes! The most common knot that occurs in this way is the trefoil knot. The figure eight knot is another one that occurs commonly. A few weeks ago, I even had a three-twist knot show up in my headphone cable.
Edit to add that recently (as of Sept 2016) a figure 8 joined the three-twist knot in my headphone cord. 
Physically, this happens because of the way cables are usually stored, and what happens when they're jostled about. Usually headphones are stored coiled up in a neat circle. When the loops of the coils pass over and under each other, as happens when they are jostled, this produces mathematically nontrivial knotting. (This also happens in other types of coils, such as garden hoses and extension cords.) 
This phenomenon was studied empirically in this paper --- I encourage you to give it a read, even if parts of it seem too complicated, the general idea ought to be easy to digest.
Another update (Oct 2018): I haven't untangled my headphone cords in over two years. I kind of enjoy watching the knots grow.

