The drift to fantasy could be because science is finally catching up with science fiction.
A good story has got to have an element of unreality about it since real life is boring (that's why we like stories). SF had its heyday at a time when we had enough science to look on space travel and life on nearby worlds as an exciting possibility, but not enough science to know just how difficult and limited space travel really is (and how inhospitable those nearby worlds really are).
That doesn't meant there mustn't be a robust underlying reality as well. World building can't strain our suspension of disbelief too much, so John Carter on Mars works only in a parallel universe - and it was a failure anyway. A fantasy world has got to be consistent. When the laws of physics are invoked they must work as per the real world. The plus side with fantasy, unlike science fiction, is that the realism element does not steadily encroach on the storytelling. Thanks to the internet, people have become very well informed as to what is and isn't scientifically possible. They want an SF story that is believable inasfar as it affirms science, and that has become very hard to pull off. When it is pulled off it's a great success, like The Martian.
There is of course always the halfway house of science fantasy where you just give scientific sounding names to magic. I don't know if that's getting more or less popular. I'm guessing that as people's scientific culture grows, believing in ray guns and hyperdrive becomes harder to do. They are no longer exciting exciting possibilities.