I often get an idea when out on a walk or a run or other times after tasting or reading. Sometimes even just a name and I decide to match a beer to it. But when I start I usually choose a base malt and decide on a yeast first, then decide what color I want it and choose 2 or 3 specialty malts to go around it. Then I choose hops.
The the hard part starts because it may take me 3 or 4 brews to really dial in what I'm trying to achieve. I usually make several adjustments before I get it where I want it and even then I might continue to make small tweaks from time to time.
IPAs are the hardest in some ways because hops change so much from year to year. Every year when the new crop comes in I have to brew a test batch and see what flavors I am getting off the hops and then I may need to make some changes to the recipe.