Many scientists are working in the same area, and papers from two or more groups that appear within a short period of time are usually recognized as having been performed independently. The advantage of a preprint is that you can post your work without any delay and therefore close to the publication date of the other work. Of course, any manuscripts submitted (whether to a journal or preprint server) should fairly cite and discuss related work regardless of where it appears.