Moshi is said twice because it is said that foxes can only say it once as もし(moshi). So when you answer the phone to say hello you say もしもし(moshimoshi) it insures you are not a fox. One story that is of a fox who turns into a woman and tricks men into marrying them.
So each night she would meet her husband as a woman and leave as a fox. The word for fox is きつね(kitsune) in old Japanese kitsu-ne means “come and sleep” and ki-tsune means “always come”. Because of this combination of the words, the fox got it’s name きつね(kitsune). Though nowadays stories with foxes are usually more mischievous. So like above, always say もしもし(moshimoshi).
The other myth is that ghost can also only say もし(moshi) once and if you answer back they will take your soul!