Some athletes arrive just before their event and leave right after. Others leave right after their events for media tours (think Gabby Douglas).
Those who consider themselves lucky to have just made it, and were eliminated in the opening round, turn the athletes village into a two week party.
Well, it depends...the national team also selects someone who would carry the flag during the closing ceremony.
Others, they leave home for their home country for media interviews (like the late night talk shows, morning talk shows, local news, etc.)
So not everybody stays in the Olympic village for the whole Olympics. Swimmer Mark Spitz also left Munich after the massacre in the Olympic village, because he would become the next target for the terrorists because of his Jewish race.
They are adults, so they can come and go as they please. But I can't think of any reason to not savor every moment of just being a part of the Olympics. I'd want to be there as long as possible.
They can leave after competing.
If they have all their events in the first few days, do they have to stay for the whole games, or can they leave when they want.