I believe that the moon is referred to as "she" because in so many religions there is a goddess (not a god) associated with the moon. I'm not so sure about the sun. I don't think I regularly hear the sun referred to as "she". If anything, if I had to associate one or the other, I would say there are more Sun gods than goddesses.
I have no idea why people refer to boats and cars as "she" although with cars it's sometimes the case that men prefer their car to their wife!
Interested in Language