The best way to prevent plagiarism when writing is to write the paper yourself and check it on a plagiarism checker tool. If the program shows non-original sections, you can delete them, rewrite or indicate citations.