The steering stem is pressed into the lower triple clamp, not threaded. It's a tight interference fit and shouldn't come out. Indeed, it's a bitch to get out if you need to for some reason.
If it has come loose (and your observation that it was rotating would seem to indicate that it has) something is very much amiss. If it wasn't a tight fit in your lower triple clamp, then that would explain why your steering adjustment kept coming loose. You didn't break it just by undoing the nut. There must have been a pre-existing problem.
I reckon you need to slide the fork legs out, drop the steering stem and lower triple clamp assembly out and check it out. Put a set of vice grips on the steering stem (below the threaded part) and see if you can turn it in the lower triple clamp. If it turned when you were undoing the nut, then it would be loose enough to turn with vice grips. If you can turn it, then you're looking at some kind of engineering solution.