All of us have read something, stopped and thought... how did they do that? What magic did this writer use to create this story, this scene, this piece of writing that has ripped my soul or made me laugh?
A very dull and boring, and not very helpful, answer is: They used their brain.
When they first began writing (like all of us here) they had favorite author influences. And most of them tried to emulate those authors. As they became more experienced they found that writing like other authors or comparing themselves to other authors didn't work. They were also learning how to use their own voice in their writing. They also realized that using the methodology of other authors was actually counter-intuitive to them (and no, I'm not saying this is a plotter-pantser thing... All writers work with their intuition to some point.)
But what gives them their voice, their style, their methodology?
Again, their brain.
And that brain has been influenced by a great many things, only a small percentage of it other authors' works.
Education plays a part but this does not mean college degrees or even high school diplomas. Many famous writers have not attended college and a few not finished high school. Education also includes life lessons.
Life lessons can be anything from seeing a loved one die to seeing a child born. It can include miserable jobs, swimming in the ocean and seeing a whale breach. Life is quite often the best educator when reaching out to a reader and pulling them into an emotional moment. Why? Because your reader is alive and experiencing life and your writing often touches them because they "know" this. Think about some of the best comedy you've ever seen. A great deal of it is something that you relate to on a personal level.
Backgrounds: This can also be part of Education. Where are you from? Does it influence what you write? Does it influence how unsure you feel writing about a setting you're not familiar with... or not? What is your familial background, from ethnicity to financial or health issues for yourself and your family or close friends? And, of course, sexual orientation and gender. That affects everything from prose to dialogue.
Turn of phrase: I'm afraid with this, "you got it or you don't." It doesn't mean you're a good writer or a bad writer. But some authors... I liken them to my grandmother cooking, you could give her a pot, a pan, a fork, spoon and knife and air, and she would make a meal you were sure came from heaven. That ability to come up with the perfect turn of phrase is absolute gold, and frankly, it can't be faked. We all have a few good turns in us, and they're a blessing. It's not something you can emulate (it just makes you look like you're cheating). Oh, and it can't be forced. It just sounds false that way.
But... if you know this is not your strongpoint you can work wonders with "plainspeak" directed to the heart and solid descriptions and dialogue, and be none the less a writer for it.
Timing Just as actors in TV or plays, the person with the perfect timing turns in the best performances. With authors this is where a good editor (or your own instincts) come in. If a scene isn't working in a spot, move it around. Don't change it because you think something is wrong with it, move it around first. Maybe it's "time" isn't at page 17 but more like page 7 or page 77. If moving it around doesn't work, then consider changing it.
Understanding: A lot of authors manage to write in different genres without any problem at all. It's because they understand the principal of the story they're writing. One of those boy-meets-girl type stories transcend all the genres and times. They understand their core story, and the genre that they want to place it in is like changing your spring coat for your winter coat. Boy meets girl in fantasy/horror/western/romance/vampire/mystery... whatever. And, they approach the story that way. They write about so-and-so who does such-and-such and by the way, it's set in the year 44,880 on in a new galaxy. Some writers do have the vision for a story set in 44,880 and how it affects them, but they end up boiling it down to the core story.
Every author has their way of working. They don't pull rabbits out of hats or wave magic wands. There is no magic, there is no slight-of-hand, they use their brains, their background, what they know, what they research and put it all together into what they hope will be a story you want to read.
A lot of what's mentioned here are things that the majority of your authors don't even think about simply because... that's how they grew up, that's how they exist, that's how they use their brain. It's a little bit of second nature augmented (if they can get it) with training. And training can be everything from practice to school. There's really no magic, it's just the ability of someone to put all their experiences to good use in story telling.
I'm sure a few of you have extras to add to this, please do. The more information we all have the better we become.
Write hard, write true.
p.s. (these are not necessarily hard and true facts, but they are observations of the years of working with a variety of writers in different fields.)