My guess would be that the Federation would give them some amount of breathing room, and enter into diplomatic negotiations with them for travel and trade rights within Federation territory. They would probably also be considered for Federation membership, although IIRC there are certain qualifications that must be met before a world is accepted into the Federation; if they didn't yet meet them, I would imagine the Federation would entice them into working towards meeting those qualifications.
During a war, they'd probably have to assign ships to defend those systems in order to prevent them from being used as bases for the enemy, and to prevent contamination from the enemy.
Or, they beam down and start trying to help them prepare to defend themselves against the enemy. (TOS "Errand of Mercy") Prime Directive may go out the door in time of war.
Not everyone follows the Prime Directive. As a result, to make it work, the Federation would have to gobble up as many pre-warp worlds as possible, so they can defend them from being contaminated by the Klingons, Romulans, etc. Basically, it's a noble idea in theory, but to make it a reality, the Federation would be guaranteed near-constant war to defend pre-warp worlds from more aggressive, expansionist neighbors.
It's not an all-or-nothing deal; the Federation most likely realizes that there will be worlds which cannot be protected and which will be contaminated by other powers. They probably try to
minimize the damage that the
Federation does, and shrug their shoulders at the plight of worlds within their enemy's sphere of influence.