Happens all the time in the US military.
Not with non-residents who don't even LIVE in the United States. They draw the line at having (at the very least) some documentation on your immigration status. You can't just walk off a boat in Miami and then slip an application to the Air Force Academy (which Nog and Jaylah basically do) no matter who's vouching for you.
Aside from the children on the Enterprise D, who lived on the ships without specific jobs?
Now that's just shifting the goalposts. Enterprise also has school teachers, bar tenders, waiters, barbers, botanists and musicians, all of whom are civilians, and NOT all of whom have any ties to family members aboard the ship. Guinan in particular isn't a relative of everyone on the Enterprise, and apart from her friendship with Picard, has no reason whatsoever to be on the ship except to run the bar and wait tables. For that matter, ask yourself what exactly Keiko O'Brien was doing on the Enterprise BEFORE she married Miles.
Speaking of marriage, I know of no military organization on Earth that actually permits romantic entanglements between a junior and a senior officer, and yet Star Trek set the precedent for that as early as "Balance of Terror" where we see an Ensign about to get married to her superior officer IN THE SAME DEPARTMENT. Officers are asked to handle that entirely among themselves and use their best judgement, which is only the most glaring example of the fact that "military discipline" is applied selectively and only to the extent the local commanding officer feels like enforcing it (witness, also, the difference in style between Captain Picard and Jellico; the former failed to notice she had been out of uniform for the last three years, the latter called her on it immediately).
Off the top of my head, the only one I can think of who lived on a starship without a job being mentioned was Jennifer Sisko
She was a physicist, AFAIK.
Also, Emissary makes it clear that Jake was conceived and born aboard a starship (probably Saratoga). This, again, would be unthinkable for a military vessel in active duty, especially for a ship that could be sent into combat and destroyed at any moment (which it was).
Truth is, no job, military or otherwise would tolerate that
The big scientific laboratories do, mainly because scientists and researchers sometimes move between projects and have to resign one post or another to avoid conflicts of interest. Also because there are only so many people qualified to even hold those positions in the first place; if you're good enough to work for CERN, you're good enough to work for CERN.
But actually that's another really good example of Starfleet's organizational structure bearing a closer resemblance to "Paramilitary-Corporate" than straight up military. I've actually worked for security contractors who operated EXACTLY this way: a few officers resigned for a few months over personal issues or (usually due to pregnancy or family illnesses) and then reapplied for and walked back onto the job without having to go through the full interview process, their employee records, background checks and qualifications still on file. For that matter, I'm also reminded that Securitas, Pinkerton and (until they got hammered for being the bunch of half-cocked cowboy mercenaries that they were) Blackwater all used military ranks and a military-style chain of command for their employees. My brother in law still does; he carries a side arm and is legally empowered to shoot trespassers at his job site, and has a rank of Sergeant (chevrons and everything).
There's "military style" and then there's
The Military. It's best not to get those two things confused.