For me it's simply a matter of convenience of searching; even pages with great and comprehensive docs can be hard to search. And the average is so poor that I often don't even bother to check if a particular project actually has a good search feature. If my search takes me to the actual doc page, (and it's good) then all the better!
For me it is often a question of what I am looking for.
If I quickly need to know how to get the last item of a list in yet-another-language, Stack Overflow will provide me an answer in about 2 seconds.
The documentation will certainly provide the answer too, but I'll need to look at several places etc., since the format is just not optimized to answer exactly this question fast.