At Carnegie Mellon, I can advise students in the Computer Science Department, the Department of Mathematics, and the Department of Philosophy. These PhD programs have different expectations and requirements, and the choice of which department you apply to should depend on your background, goals, and interests. Admissions to each of the departments is competitive. Decisions are carried independently, and there is no harm applying to more than one department.
There is no formula for admissions decisions. Faculty generally survey all the available information, looking for evidence that prospective candidates will succeed in the kinds of research they value and support. You can get a sense of what that is by browsing a faculty member's web pages and those of their students; these is the best indicators of the kind of work you will be able to do under a faculty member's supervision. From their perspective, the best evidence for the kinds of research you are capable of doing is the work you have done in the past, and what those who you have worked with have to say about your interactions with them. Nonetheless, transcripts, your personal statement, and other components of the application are important too.
Success in graduate school requires meeting three key constraints: you need to find a project or projects you are excited about, you need to find an advisor that is willing and able to advise you, and you should generally keep in mind your long-term career goals, even if they are uncertain, and do your best to ensure that the work you are doing is going to get you where you want to be. You don't have to get this right from the start; exploration, reflection, and continuous re-evaluation is important. Nonetheless, you will be trying to optimize under these constraints throughout.
When applying to a department, it generally helps to indentify a few people you may be interested in working with. There is an art to portraying yourself as focused, but not too focused; faculty want to see that you share specific interests, but also that you are flexible enough take on projects that you might not anticipate or imagine now.
Applying to graduate school is stressful, but it should also be exciting to think about the possibilities. Don't get your heart set on any one program or advisor, because even in the best of circumstances, there is a lot of luck involved in the admissions process, and there are several places you can thrive. Also, keep in mind that there are pros and cons to graduate study; it's not for everyone, and part of the application process involves determining whether it is right for you.