My best friends from uni are probably on my course and one other we share lectures with, we just seem to have more in common. So me people get really lucky with flatmates, but from what I've seen, most of the flat mate "groups" don't stay in touch as much after uni, whereas those who are friends for another reason do.
My course is really cliquey though, so while my best friends are on my course, I'm probably only really friendly with about 25% of people on my course.
I think the difference is you can be happy without really getting on with anyone on your course, but if you start falling out with your flatmates then things can get really miserable as you do have to live together.