Why are the pronouns "she" and "her" used in place of "it" for spaceships, aircrafts, submarines and so? I heard it in many American movies. For example one would say to the captain of a submarine while going down and down "Stop going down or you will lose her".

Almost always these vehicles have names, eg, "Red October", Millennium Falcon" and play important roles in the story. So it would seem natural for them to be a little humanized, or at least considered living beings. But why just female beings?
Is it because they inspire a sense of protection, nourishment and survival, as a mother would do, expecially during battles, or is the explanation to be found absolutely elsewhere?

In my language, addressing a ship by "she" is just the natural way, because "ship" (nave) is a feminine noun. The same is for "spaceship", (nave spaziale or astronave). But not for "submarine" (sottomarino), which is masculine. One would say to the captain of a sottomarino "Ferma la discesa o lo perderai". However, if the submarine in question had a woman name, eg. Priscilla, then the sentence would be "Ferma la discesa o la perderai".
Incidentally, can't figure out how funny it would be to hear "Priscilla ci ha silurato!" (Priscilla torpedoed us!)

Franco - there's no grammatical reason - it's just an historical linguistic phenomenon and has nothing to do with the noun itself. We also refer to cars as 'she' and 'her' even though strictly speaking, as inanimate objects they should really be genderless - it's just a quirk of the English language.

Thank you Davide and Calum. It was simpler than expected (of course! ).

From your links:
----------
"Lloyd's List can do what it wants. The Royal Navy will continue to call its ships 'she' as we always have done. It's historic and traditional," he said.

"Ships have a soul. If I remember my history, they are female because originally the ship was the only woman allowed at sea and was treated with deference and respect - and because they are expensive."

The British Marine Industries Federation also said it had no plans to change.

"Our owners have always referred to them as 'she' and will continue to do so because, to many, they are part of the family," a spokesman said.

Among the theories as to why ships are referred to as female, one claims that crews believed the ship represented their mother, another that it is because early ships were dedicated to a goddess.
----------

As a Italian, I find this article particularly nice and can't help to think that the Royal Navy is right.
On the other hand, I said that mom was involved in a way or the other. The Italians are so experienced in moms!