Is it ethical to have two (undergraduate) researchers in the same group "compete" against one another for leadership/credit of a research study?
Let me try with an "onion-answer", one layer at a time.
It is certainly not unethical to have several undergraduate students work on the same project. This is how most people get by, as there are simply not enough interesting and unique projects at undergraduate level that everybody can get their own. (And if there are, it would take too much time developing them.)
It is borderline unethical to set up a competition between students in your lab, dangling the prize of a conference presentation or a publication ahead of them. The focus should be on how to do good research, not how to get ahead of your colleagues - even though it is sometimes also part of research. I can see how this could be done in a somewhat fun and productive atmosphere, so I will not dismiss it off hand. But I would much rather have the students work together, than against each other.
It is blatantly unethical to have a competition among your undergraduate students without informing them, that they are in a competition, first. I assume from your post, that you have never said yes to be in such a competition, and that you in good faith assumed that your chances of getting the "prize" would be based on your performance alone, and not how it compares to the performance of other students. This is a kind of "bait and switch" strategy, also often used for job interviews, where you get a person in the door by promising them a reward - but at the end of the day there is only one reward, and many people competing.
Finally, you mention that part of the prize is also "credit". Here I want to tell you, that if any scientific work is done towards a specific publication as part of the non-winning studies, the authors of said work should be credited as co-authors. Even if they don't win the competition.
I might actually have to applaud that professor, but only under certain circumstances. If you were in "competition" with each other for grades in some course then no, it would not be ethical. But then, I normally define competitive grading in general to be unethical. It should be possible for every student to succeed and even to get full marks in any course.
But there is nothing wrong with getting truly independent thought processes going on a research problem. You were given the opportunity to solve a, perhaps hard, problem using your own resources. There is a lot of value in that, both for yourself and for science.
Search around for information about the search for how DNA works (Double Helix). There were independent groups that attacked the problem from different angles. It was a rather extreme competition to be first.
But, I don't think the professor wanted you to sabotage one another in the search and they were correct that one or maybe several of you had the potential for publication. In fact, different approaches to the same problem can each be worthy of publication since the path to a solution is often (some fields, anyway) even more important than the final answer.
And if the professor is wise enough they will recognize that for a budding scientist the search itself is valuable even if unsuccessful.
If the professor was willing to reward everyone for their work, not just the first over the line, there there is nothing wrong with this, and much to be admired. You may want to thank them someday for that experience.
Having two undergraduate students compete against each other is probably not unethical, but usually is a bad idea.
Duplicate research is wasteful, and may be unethical. For students, the purpose of duplicate work might be duplicate training, which is not unethical. A supervisor might assume that undergraduates are unlikely to complete a project, in which case duplicate effort is potentially appropriate.
Assuming that duplicate effort was somehow justified, framing that duplication as a competition instead of a collaboration is inappropriate. The goal of research is to create knowledge, not to create winners.
Assigning the same project to multiple people without telling them is also obnoxious. But obnoxious does not imply unethical.