How to prevent these things is a good question. Have you contacted ancestry.com?
As to their inaccuracies, yes, there are many, mostly because people can submit their own genealogies. Anything you find, treat with a grain of salt. National records were begun in the U.S. about the time of the Civil War. Other nations began theirs even later. (This means that persons such as myself can get records only from church records or individual family genealogies; there were no official records that far back.)
To compound things, records were written; wars caused the loss of many records (such as the Civil War); fires, termites, rats, you name it.
However, if you go back a few centuries, just about any name you can find is probably an ancestor of yours. So, perhaps the person "correcting" your tree found your ancestors on their tree, or, quite likely, they did not thoroughly research things and found the same or similar name and just assumed it was theirs. In my case, about 10 generations ago, I had 2 "grandmothers" with the same name born at the same time. They had the same grandparents (they were first cousins). Both were born in Germany; one immigrated to Virginia, the other remained in Germany. My point is, that until one researches from every which angle, it is difficult to know where people fit into their tree and people often don't spend enough time and effort.
Contact ancestry.com and report the situation and ask them what can you do (besides keeping your tree to yourself, which is what I do).