I invented something and want to apply for a patent. How can we prevent the same patent from being applied by others?

You can't stop others from applying for the same patent, mainly utility model patent. Because the utility model does not undergo substantive examination.

But it doesn't matter. If you find that someone else has applied for the same patent after your patent application is published, as long as his application date is later than yours, then you can go to the Patent Reexamination Board to make the patent invalid, so don't worry.