In the first place many countries give you a new visa on arrival. Only those countries which enforce a limit of "so many days out of such and such", like only 90 days out of 180 will trouble you at the border.
Find out before you leave the country. Don't try to fool them by a subtrifuge of using a different passport. That is a opportunity for expulsion or arrest if they figure it out, and intent is important.
HOWEVER, Many countries simply allow you to leave and then immedately come back for a new length of stay. This is called a "visa run".
If that is permitted you can leave the
boat, do a visa run, then come back and rejoin your
boat.
In
Thailand we had to apply for extensions, which had a fee (probably a bribe, but I got a receipt from the immigration official in the office) and we stayed for three years after which we made a visa run to Mayanmar.