That depends. If you declare you are not registered at all that makes you an illegal pirate with no protection at all. If someone else with a yacht decides to sink yours that is probably legal for them - if you fight back they can call their navy to defend them. Regardless of who their yacht is flagged under calling their navy for help probably means they asked the nearest navy (which is almost always the US navy - even if the US hates the country in question the US doesn't want the seas to be a free for all and will come) to help.
If you become self sufficient out there probably nobody will care and you can be there for years no problem. Just don't cause problems and nobody really cares. However if you cause problems expect issues. If one person on your yacht steals from another that is your business, nobody will get involved. If someone steals from someone with a country that country will get involved to protect their own. If kids are born on the yacht they might not have a country which could make life hard (particular as the yacht gets old and is no longer safe!). If you have kids born and then sexually abuse them several countries (in particular the US with their large navy) have declared that illegal anywhere and so they will come in to stop you.
The hard part is to become flagless in the first place. What every country you set out from will just assume the boat has their flag by default. They generally won't let you choose to take it off - they will let you sell it to someone in a different country and then change the flag, but there is nobody with no country who can take ownership of it. Maybe a lawyer can find a work around, but it will not be easy.