If you want to become a PI all you need to do is secure lab space and gain sufficient funding. Of course, that last bit typically requires you to prove you know what you're doing (PhD and evidence you've used all the techniques you're going to use before) and have the equipment and collaborators necessary for the project. Considering that even highly successful and talented scientists have a difficult time getting funded, I wish you the best of luck in your endeavor.
Now if you just want your own project, all that requires is coming to your PI with an idea that is both good and is something that fits the PI's interests. Or you can just do what most people do and ask your PI to hand you one of the many projects the lab has on the back-burner for you to go wild with. The latter is far more likely than the former. In my four years of research experience spanning three labs, and having seen around a dozen undergrads do projects as well as two masters students, I've only ever seen one person come up with their own research idea which they then presented to their PI and got turned into a full fledged project. And that person was me, as a lab tech, after I had three years of experience, a degree, a thesis, and a publication under my belt. I was also on very good terms with my PI, and I proposed it at a time when we were looking for a new project anyway. And even then the project ended up getting handed off to a master's student anyway because she needed a thesis project and as a lab tech I have to oversee everything in the lab, not just one project. So that should tell you just how common it is for people to be given projects, not make up their own.