A lot of the time I write the solo first and then the riff, anyone else ever do this? Is this a bad habit?
course not. you can do whatever you want.
Gibson Les Paul Studio
Squier Classic Vibe Tele
Fulltone Clyde Wah
Fulltone OCD
Fulltone Deja Vibe
Fuzz Factory
Carbon Copy

Boutique Marshall-Style 50watt amp head
Orange 2x12
hyperboy is right, in songwriting there are no rules or bad habits. Unless you use the same progression over and over i guess. I find inserting a solo where it feels right after I've played the song with my band works the best for me. Do what works for you though.
there's nothing wrong with it , but if you wrote the riff 1st you'd have a good idea of how to make a solo that also relates to the riff and make it sound more sophisticated
Hell, if you think about it, it may be better to write the solo first because you know it can stand by itself and not rely on the riff being in the background.
actually, i do the same for most of my songs, but its not a bad habit. its like saying "do you write firs the music or the lyrics?"(assuming that its not an instrumental song)

It's not a bad habit, but you have foreknowledge of what the progression is going to be, or base the progresson off of key notes in the solo, it probably won't sound great or anything. My thought, anyway.