i.e. check it doesn' leak when in sevice !
Do you honestly think that? It is on sea trials, not in service. Not a full complement of crew, civilian testers, checkers, etc and likely no armaments and only enough of anything to prove the systems.
You seriously don't think they run the screws at full speed while in port, do you?
Of course they return to port – to remedy any faults found during the trials. That is what the trials are for – to find any faults. They will have tested all they can before doing the sea trials.
The ship was built to a specification. It will not be accepted as fully functional until commissioned properly – ie checked carefully to prove it is to the specification provided to the shipbuilder.
Finally, do you know how aircraft are tested before they first fly? They are not just rolled out of the hangar and flown off the runway!!