This is my opinion and just that since I raised two boys who are now into adulthood and doing quite well:
1) Kids watch parents by example. And by that, I don't necessarily mean "right and wrong" per se although that is important. I mean, strength of conviction and being in control. If you believe something (righteous) and live it, even if you "fly off the handle" sometimes that won't rock the kids' foundation and they will tend to emulate you. I'll give the specific example here. My kid did a report of a certain president of this nation I was always interested in --- he saw my respect and adamant devotion to the man when we took a family vacation to New Hampshire to see his grave, and that of his wife, and when he did a report on this same president, I was both flattered and surprised. This applies to spirituality as well.
2) A corollary to point #1 is that if the parents do not have a strong conviction (and don't confuse conviction with legalism and being strict) and otherwise do not know where they are going as a goal, then the child will naturally try to find a way that satisfies them to fill that void. Human nature being what it is sadly takes the form of derogatory behavior.
3) One other thought, if a parent tries to "live their lives through a child" and otherwise are harsh in what the child wants to accomplish and instead define their goals for them, then the result will be rebellion. There's ways to teach righteousness without saying "you can't do that" and thus squelch the child's ambition. If there's a tendency to sin in some area, then find out what the motivation is and direct the child to a constructive outlet, and also make it clear that the constructive outlet can be something they want to pursue and why sinning and hurting one's fellow man instead is not cool.
To wrap it up, if a parent does fail (not always the case), then maybe its
1) They don't know in and of themselves what they are doing as a goal (lack of direction both for themselves and the kid) or...
2) They are thick-headed themselves and always ragging the kid instead of finding constructive outlets, and not letting the kid being their own individual.
Now, for people who have kids well into the teenage years that act as if they are 17 years old going on 8, then they have their work cut out for them to undo years of bad family dynamics. I don't want to say it's beyond hope, but in some cases they are ingrained already and the usual punishment of taking away the Internet or taking away the cell phone is the only thing that will work and will provide temporary symptomatic relief, but nothing will change and they may very well go into full adulthood permanently alienated from their parents. Sorry about that.