Some land-locked countries still have navies. They use estuaries going through other countries to get their boats across. Might sound weird, but there you go.
Captain Georg Von Trapp was a Submarine Captain in the Austrian Navy during the First World War. At that time the Austro-Hungarian did have an extensive sea coast including much of the Baltic when the country was defeated in the War the boundaries were changed and Austria did indeed become land locked. check out your history!
The movie never says that the Captain was part of the Austrian Navy. The Reverend Mother says that he was in the Imperial Navy, which would be correct.