As a general rule, these are the different offices that you may be required to check into:
In quite some countries the very first step. You may not be allowed to 'move around' until cleared by quarantine.
Normally with a complete crew list and all passports.
For declaration of taxable goods, arms etc if any.
Boat declaration with boat documents and in some cases even valid insurance documentation!!
Check entry procedure BEFORE entering as some countries demand a pre-waning like Australia. Just showing up on the doorstep there may send you straight to jail!!!!!!!
Another thing to check out before entering is that you enter in a 'port of entry'.
If sailing in the Andaman Sea, and traveling from Thailand/Malaysia, you have to go almost all the way to India, it is only one 'port of Entry'!!
In general the Caribbean islands are quite 'relaxed' except for the US territories!!
The Pacific likewise except for the 'Tuamoto' with Marquesas and Tahiti. Be prepared to post a 'bond' equal to a one way ticked to home country for ALL crew!! You get it back when leaving, but in useless old Franc!!
In Europe , you may come and go most places withing the Schengen area, just by checking into one country, but note that UK is not a Schengen member.
A non-EU boat may only stay for a limited time, or you risk to be taxed heavily!!
Unfortunately the 'freedom of the seas' is not quite what it used to be.