Depends on the succession. If, somehow the primary (and only) county level title of the king is lost, they will randomly take a title from a random vassal, without their consent. That usually happens as a result of the liege losing a holy war.
Looking into it, I see that the new King was installed by faction demand.
Following on from what you have said, what I think might have happened is this. There are four counties in the duchy I am in. Two were controlled by me, one was controlled by the Duke - my liege, who became King - and the last county by a vassal Count.
So, if the King was ousted by faction demand, someone else became king and took the capital county of the kingdom, which is in my duchy. The usurped king was still a duke, but now had no counties in his duchy, or even a duchy at all, and therefore automatically usurped and took control of one of my mine - my main one.
Possible?
Now I have a new problem.
My Count died from wounds sustained in battle while leading his mercenary army trying to reclaim my main county. So the war ended. I still have my mercenary army, so I disbanded my levies and exited enemy territory. The new Count does not have the option to declare war for a claim on the county that was recently lost, only for a war of liberation, to free myself from the duke's vassalage.
Why can't the son of the guy who just got his main title usurped and died in battle trying to reclaim it continue the war to reclaim it? Will I have to fabricate a claim on the county?