Practice probably helps. I remember being able to clearly visualize things as far back as when I was a kid, but I never thought there was anything notable about that until the NPC meme came out a few years back and I found out most people couldn't do it. Never really thought about how to improve something that I thought everyone could do.
In all seriousness, practice.
Maybe some books.