It is standard practice to lock turnbuckles. This is why each threaded part has a small hole in its end.
Some makes have small screws threaded into these holes but others simply use stainless steel cotter pins which should not be reused (though many people do!) - or welding wire - thanks for the tip Roger.
The reason yours kept coming apart was probably because, in the haste to reconnect it under way, you may have put put several twists into the rigging wire. As soon as the load came off the wire simply untwisted itself and unscrewed the turnbuckle.
You will notice that the lower half half has a thread in the opposite direction to the upper half. The idea is to undo both halves completely and then offer each threaded part to the main body at the same time, rotating the body so that each screw takes up the same amount. Whilst doing this don't allow the upper screw to turn as it will put twist into the wire again.
Tighten up the same amount on each side of the boat and then pull the main halyard taut down to the deck fitting on each side of the boat to check the mast is upright.
Put a cotter pin temporarily in each hole and expand it just enough to stop it from falling out.
Then go sailing.
Sail on one tack and see how slack the lee shroud is. Pull the cotters out and count the number of turns the body needs to just remove the slack in the wire.
Now undo half this number.
Tack and put the same number of turns on to the other shroud. i.e. half the number you first put on the other side. Thus you will have actually added the same number to each side.
Re fit all the cotters properly bending the legs open and you are done.
It seems likely that none of your turnbuckles were locked and very likely the rig is not set up at all well. I suggest checking your mast rake before doing any of the above by hanging something heavy (like your toolbox) on the main halyard, on a calm day, and noting how far behind the aft side of the mast it hangs when just above or below the goose neck. Most boats like about 1° of rake (6" in 30' of mast). Do this check and adjust if necessary before setting up the shrouds.
You might also like to cover the sharp ends of the cotters with white tape to stop them tearing sails and people. Don't cover the whole turnbuckle though because stainless steel needs to be exposed to avoid corrosion.