How can I become part of a patent if someone has the same idea. Do I have to buy the idea from them? Or is it possible to move forward with the person who has created the same idea?
Bogdan's answer used to be somewhat true in the U.S., but the U.S. is now a first-to-file (really, more like first-to-disclose) system, thanks to the America Invents Act (AIA).
You would need to be able to show that you had published the idea prior to the application being filed. Website postings and the like can be used as long as you can prove a date by which they were available.
All patent systems share this in common: they grant a limited-time monopoly IN EXCHANGE FOR public disclosure of the invention---so that others can learn from, improve upon, and use the invention (maybe only after your patent expires, but still). Doing something at home, without ever having publicized it, doesn't count as public disclosure.
If they are willing to work with you, then you can be co-inventors and share filing fees, etc. Otherwise, you can both file at the same time, and the one that can prove earlier claim date would get the patent. If the other person has already filed for a patent, then you are out of luck, unless you have some very good proof that you started to develop and test the idea before the other person came up with it. It all depends on the situation.
You can, of course, purchase the patent from them, but anyone can do that.