Why do shoelaces untie themselves and earphone cables tie themselves up? And if that’s the case, can’t we just interchange them?
It actually because of Entropy  i.e.; Systems always tend to move to a state of higher disorder for more stability. Means with an average length of a earphone, there is a 50% chance that it will knot in your pocket or bag.
As per scientific studies it was concluded that the longer your cable, the higher the chances of it knotting, due to the face that ‘system’ in case of shorter cords will relatively less tends to instability.
Though few factors will act as a catalyst such as,
for shoelaces, they are slick and/or round in shape. Round polyester or nylon laces are the slickest and hardest to keep tied. But it also depends on the whipping motion created while walking or the hems of your trousers / pants brushing against them etc.
for earphones, (or any bunch of long, flexible objects), as per knot theory, the linking in a number of places, with enough contact points, increases the chances for these objects getting into one of those ‘knot’ states or the more contact points, the more possible knotted states will exist.
Conclusion: Hence as per entropy and knot theory, a cord lesser than 50 cm would almost never tangle itself. But if the length goes beyond that, the probability shoots up till it gets flattened at 2 meters.
As a solution, you can use ‘untangle’ earphones or fabric cord earphones (like this one) which are a little costlier though. And for shoelaces, just google for reef knot, which is way stronger than the usual granny knot 🙂