I always thought it was because they take so much time and money to keep them running properly. If you don't put time and money into your ship it will break down on you. Just like a women doesn't like to be neglected neither does a ship. At least that's what I have always been told.
It comes from ancient mariner tradition that no woman ever set foot on a ship lest the ship become jealous. It is still tradition since most navies of the world until very recently did not allow women to serve on board