It's because the two genres are pretty much the same. They're both about exploration into the unknown. One happens to take place in the desert, the other in space. Both are bleak environments where survival is a daily struggle. Both tend to deal with lawlessness, because there's too much area for the law to be enforced.
Westerns deal strongly with encroaching technology, such as railroads, the advent of semiauto and full auto weapons, the invention of dynamite, the use of technology for superiority (such as guns vs. bows and arrows). A strong theme is where do the people fit in with all this change. You have ranchers moving through, then oil barons, and it's all technology and business and economics and what happens to the little guy? The cog in the machine, the stories of the people.
All of those themes apply to Science Fiction. Thematically, westerns and sci-fi have always been the same genre. They are far more closely related than sci-fi and fantasy (although I often argue that fantasy isn't even a genre, it's a setting. There's no real thematic rules for fantasy, just standards for the world it takes place in.)