Few people know how to write characters, especially new ones, so they write what (and usually who) they know: themselves and their friends.
But how are characters going to talk to you? Aren't you writing them!? You can't surprise yourself for the same reason you can't tickle yourself: because you know it's coming.
The trick to getting out of this trap is to approach your characters differently. Instead of saying, “what would I do in this situation?” you ask, “what would this character do?”
The trick is to make the character contain as little of your own personality as possible. Would you normally high-five someone after thwarting a villain? Make sure you characters don't. Do you hate classical music? Make your character enjoy it. This will stretch your imagination and help you start think like somebody else. This way, when you put your character into an uncomfortable situation, you're already thinking like him and hopefully while you're inside his head, he'll come up with something that you wouldn't.
This is tricky because you might fall into the trap of making your character so far removed from yourself that you no longer have things in common. If this happens then it will be much harder to write. Think of this: You want your character to be your friend, not your enemy.
As for the minor (read: Not main) characters, if everyone's getting along all the time then you've got some more problems. People don't like reading this kind of thing. It gets boring after a while. Conflict breeds interest, as the saying goes. It's very true. Watch any movie or television show and you'll see that the main characters don't always get along. If they do, then they'll at least have rough patches in their relationships. The audience is more interested in seeing how the characters resolve these conflicts. I don't mean to say your characters should be constantly fighting, because that would be just as bad.
This doesn't mean that they're in violent conflict, either; it just means that don't see eye-to-eye in All Things.
“But my characters still seem flat, William,” you might say, “I've followed all of your ridiculous William-Rules and I've come up short yet again! You have failed me, sir!”
Of course your characters are going to be a little flat at first. It's hard to figure out how to make characters interact with each other without seeming like a pained exchange between two sixth-graders. Some authors get it right away and some never get it. Look at the New York Times Bestseller list and I guarantee you'll find some books on there that are actually quite horribly written.
I'm not saying that after your tenth book your characters will magically gain another dimension and jump to life. It doesn't happen this way. Like everything else, it takes loads of practice. If you want to see examples of great characters, I recommend reading the Harry Potters, anything by Diana Wynne Jones, most anything by Eric Nylund, Charles Dickens or Oscar Wilde. If you like television, watch anything created by J.J. Abrams. Alias and Lost are particularly strong in this department, because their characters are constantly in conflict with each other. In J.J.'s Star Trek reboot he took (what many people would call) stuffy, boring and characters and made them amazin'. And that's to say nothing of the phenomenal Fringe.
What's the secret to making characters seem like real people? Their mistakes, overreactions and neuroticism. But what does that mean?
Lets take Spiderman as an example. Unlike other more supermanly heroes, Spidey is almost always being kicked around, berated or otherwise abused. He hardly ever gets what he wants (Mary Jane, a paycheck, the bad guy) and when he does, it usually costs him something else (uncle Ben, a date). He's almost the perfect picture of tragedy, except for the fact that he's so funny and lighthearted. He's constantly cracking jokes and making fun of villains.
You might say that his imperfections make him so fun to read (if you read comics) or watch in the cartoons or the first two Spiderman movies.
If you took him too far in the imperfect hero direction, he'd become Dexter, and many people don't want that.
If he didn't have these weaknesses, he'd just be a guy in a suit saving people (Spidey, not Dexter). Everybody has to have weaknesses, and not just super heroes. These weaknesses make the character better, because them they have the opportunity to improve over the course of the story (or series or movie).
“Okay,” you might be saying, “I've got the formula down:
Sad but funny
I'm gonna go and write my story, and I'm gonna make a million dollars from it!”
Hold the phone. The formula you've just created could be the same that Woody Allen uses in his “movies.” You can't just go and make all of your characters like this. In fact, maybe you shouldn't follow my advice at all. Certainly not all of it at once.
At this rate your character is gonna be so weak and exploitable that he would no longer be fun to read. What I'm really trying to explain is depth.
With anything, take my advice in moderation. You want your characters to gel with others; to compliment each other's personality. Don't make anybody perfect, unless your goal is to make a person annoyingly heroic.