I suggest you make a complete backup of each tree (including media etc, but not including the sync data), first of all; then you can restore if something goes wrong. Excluding the sync data means a restore won't immediately rush off to find and sync.
Then, for each pair, unlink the tree which contains the most errors, so the version on your computer is not linked to Ancestry. Then, in Ancestry, delete the tree. In theory that should leave you with one linked tree (the most complete). If that works OK, you can then delete the unlinked, less accurate tree on your machine - again, for each pair - work on one at a time!
It may be that each pair is not fully complete. If this looks to be the case, do a merge on your machine. Normally this will produce a list of those individuals recognised as being the same in both, plus those which only appear in one. It may ask you to confirm which details are your preferred ones. That should produce one tree which definitely has as much as can be extracted from the two in each pair. Worth looking at before you do the above.
As to preventing this happening again, the best method is to backup to an external hard drive - which could be a large thing like MyBook or a USB data stick. Then if you crash you'll have the complete tree to copy back to your main drive and it should match the Ancestry one. Remember to copy to the external drive both the tree file (xxx.ftm) and the Media folder for that tree. Most easily done by copying the whole FTM folder.
And the external drive can be used to backup any other data files you have and don't want to lose, of course!