We all carry scripts in our heads. I'll say this, then they'll say that, and then I'll say this and ha! that'll show them. Trouble is, people have their own ideas and follow their own script. They haven't read yours so do things you'd never do, say things you never thought they'd say.
When I'm teaching a class exercise, rather than putting up words or phrases that I've thought of, I ask for contributions and put them up on the board. This isn't because I'm lazy (well, not only) but because I've learned that there will be a far greater range of ideas than I could have thought of, some going in directions that hadn't occurred to me before.
Our characters have to follow their own scripts, rather than obediently going along with ours. They have to speak with their own voice, not ours. They have to do their own actions, not ours. They need to have their own tastes, not ours. When you've got a character who is following their own script, not yours, you're in that situation where the characters seem to write themselves.
How to get there? I think there are probably as many ways as there are writers. I usually write my first draft not really knowing and during the writing I start to 'see' my characters. Actors sometimes say if they get the shoes right, the rest of the character falls into place. I normally know what their hair is like before I know anything else - in the book I'm writing at the moment, I know my main character has black hair in a Louise Brooks type bob and is fond of black skirts with bright, bold applique. Once visualised I understand their quirks a bit better, their tastes in food, music, cars etc. Then I start hearing their voices more distinctly. Gradually they become real people, just as tangible (to me) as my friends and family. And like real people everywhere, they don't follow my script all the time.
Perverse, isn't it? As a writer you control your characters, but the writing is best when they control the script. How do other writers get there?