For me, it's a variety of factors. I read a lot about travel, so when it's time to plan a trip, I usually have various ideas. Sometimes, a place that has been percolating in my thoughts for years will suddenly call to me as "time to visit now." Other times, it's based on external factors (often financial), such as my recent trip to the UK; I had been thinking about visiting for a while, but seeing the drop in the GBP against the USD made me do it now. I do check airfares before getting too attached to any place; I figure I can always visit another time, so if fares are very high for my dates, I go somewhere else. However, I never go to a place just because it's cheap; it also has to interest me.
One thing I'm very careful of is not to book anything definite until I make sure it works with the other parts. For instance, I won't book airfare until I've sketched out the trip, so I know my start and end cities. And I won't book accommodations or finalize cities without checking airfares. For instance, when I went to Madrid and Barcelona, it was about $80 cheaper to fly into Madrid and out of Barcelona than the reverse - so that's what I did.
Once I do know where I'm going, I try to read as many travel books, websites, etc as possible. Each one can give ideas the other ones lack. I then decide which ones I'm most interested in, and plan around them. These days, I also plan carefully for any places where advance booking is recommended or necessary (more and more places every year fall into this category). For instance, on my recent trip to Liverpool, my days were uncommitted (I had lists of various attractions I wanted to see, but no set schedule of what I would see which days) - with the exception of my National Trust tour of the Beatles' Childhood Homes, which was booked long in advance and therefore set in stone. Other than such pre-booked things, I'm not afraid to change my plans on the fly. If a museum I had planned to see doesn't interest me when I'm actually there, I skip it; I also do this if I'm feeling tired and need a break (I really wanted to see some more places on my last trip than I actually did, but not at the cost of pushing myself and then not feeling well).
For large cities I haven't been to before, if I'm staying more than 2-3 nights, I try to have potential day trips lined up. Even if it's a place where there's no shortage of things to do, if I'm not happy there, I need to "escape" on a day trip to somewhere else. If I am happy there, no day trips are needed. For smaller places, I try to limit my stay to match what there is for me to do.
One thing Rick said that has stuck with me is that each trip would be better if you could do it twice - once as rehearsal and once as the real thing. Now that I'm going back to some places where I had a bad or compromised first trip, the second visit is much better (this happened in Amsterdam, Madrid, Barcelona, Toledo, and Venice, among others). So, no matter how much planning and research you do, there's no substitute for the real thing (sort of like how driver's ed classes can only go so far - you have to get behind the wheel).