First, there are the fortunate few who enter graduate school already knowing what they want to do research on. These types pretty much already have an interest that is specific enough, and all they're doing is finding an institution that can host them to do this research. Second, there are students who have a general interest in the field, but they don't know what they want to specialize in yet. And of course, there are plenty of people that are somewhere in between these two poles.
Personally, I guess I was a hybrid. I came into my graduate program thinking that I wanted to do X, but due to internal and external circumstances, I ended up doing Y, which morphed into Z. Somehow, one thing just led to another.
Anyway, so how does one find a research topic? Well, it depends on what type of student one is. Note that as I graduated from the North American system of graduate school, my opinions will be tailored toward this system. I am well-aware that the European system differs quite a bit, and that is something I don't have much knowledge of.
In North America, at least, getting a PhD degree involves taking courses, as well as doing research. If one already knows what one wants to do research on, then it is advisable to tailor one's term papers toward this research topic. After all, the closer these term papers are to one's dissertation topic, the easier the dissertation will be written. These term papers can eventually form bits and pieces of the dissertation.
On the other hand, if you don't know what your interests are yet, then I suggest spending the whole first year taking a diverse set of classes in order to find out what keeps your academic boat afloat. Most programs require people to take several classes to fulfill a breadth requirement; this is a good use of that. Talk to professors and discuss their research topics and see whether there is a particular one that interests you. Once you find out what you think is interesting, then the research topic will shortly follow.
It goes without mention that reading is a substantial part of this process. After all, it sucks if you think you found a research topic, only to find out that someone else has already done it, and published it. One must carve one's own corner in the academic space, and this involves a lot of reading. One must make sure of what has already been done, and what is still up for grabs. After all, once you write the dissertation, you will be a specialist in that topic. During the early days of my dissertation, I remember my adviser telling me one day, that at the end of the day, I will know more about my topic than him. Eventually, the advisee will outshine the adviser, when it comes to knowledge of the topic. The adviser has his own research program, after all, and the student begins as an offshoot, but eventually takes the centerstage later on.
So there, those are my two cents with respect to finding a research topic. If you're a masochistic academic like me, who finds discovering new things about the state of the world to be fun, then graduate school is for you. Good luck!