Here I Stand
Do ships in a port take part in a land battle there, or retreat with the land units?
No. Naval units are ignored in land movement and field battles, so ships in a port cannot avoid battle or retreat with the land units, and they stay in place when the land battle ends.