The rules are a bit vague on planet control, but I think that basically you retain the control markers as long as a unit is there, they do not increase if an enemy unit is contesting the plant, they lose those markers if their unit is destroyed or forced to retire, and the enemy unit will then start getting faction markers if it remains on the planet (and is now uncontested).
e.g. A Commonwealth cruiser is currently controlling a hex on the planet and has been there for two turns, thus accumulating 2 markers. A Confederation destroyer charges in, attacks the cruiser and forces a retreat due to rolling a hit and 2 red alerts. The marker accumulated by the cruiser are lost since control of the planet has been lost. On the other hand, the Confederation destroyer will now start to gather markers of its own each turn since it is now the only remaining unit and so the planet is uncontested.
I think this is the way the mechanic works, although I could be wrong of course. I think it makes most sense anyway. Hope it helps