Practice, lol.
An Unique Problem Perhaps!

You should play with real players rather than computers.
The same problem of bad position in opening i was facing before a month.
But Now I am able to develop my all pieces in opening because I am preparing openings now..Every chess video and lession will tell u that develop yo ur minor pieces and than major pieces.But they dont tell u that How to develop tham with plan .
So here is solution of your problem:Prepare openings and than watch games played by strong players.After watching there games,you will able to plan in real games.Planning is important part of chess. Mostly ,players know opening basics,but after nice opening development, they dont know how to Plan in middle game.So, i reccomend you that you should play fixed first 8-10 moves in opening.For an example,If u play e4 than prepare aga inst e5,c5,c6,d6,e6...Mostly players replay with e5 and c5...so prepare opening..And middlegame and endgame is importnt..so give equal time to them .

And that's why relative beginners are advised to study tactics rather than openings. Essentially you have to earn the right to play "properly" by showing that you know how to punish folks who don't play according to the principles of chess. As your rating rises you'll find much less nonsense going on. It's a common problem; I may have faced it myself.

ya..Most of begineers dont know how to avoid traps in opening and how to punish those wrong aggasive moves.So you should read yasser serewan's opening chess book...You should read basic chess books like "your first move. It was my first chess books a n d really effective.

It could also be an unconscious fear. When I started playing chess I had the same problem but it went away for me after a while. I used to play only against chessmaster grandmaster

Chess_dashing - Thanks so much for the advice. I guess, I have to prepare for normal opening tricks. And those surprise and non-technical attacks. As Baddogno says, earn the right :-) But Baddogno, most tactical puzzles are either based on middlegame or endgame. In fact, my biggest problem is the Scholar Mate attack. Even though unsound, it totally messes up with my kingside preparation.

This might be helpful. First, review the games you've already played and lost, to see where you went wrong. Try to identify as many blunders as you can by yourself but don't hesitate to let am engine point them out. You don't want to spend all day trying to figure out one move. Be sure to replay your games with a data base program that includes an opening move tree, so you can, at the same time, observe what some correct moves would have been. Unfortunately, opening theory is very complex, so there's usually two or three good moves for any position. At first, don't try to memorize too much, just start becoming familiar with common maneuvers and pawn structures, and pawn breaks (pawn breaks is an aggressive pawn push that usually attacks the opponents center and helps to free your position and/or give you the initiative.) It takes time because of the complexity, but if you do this everyday or regularly, over time, you will begin to connect the dots and gain a bigger picture of opening play. Hope this helps.

The reason you think your playing better against Stockfish is that the engine isn't going to make crazy, shallow, threat moves in the opening. Unless it can outright win major material. Instead, it's going to develop first, and then, once that's done, you won't have a chance, lol.

yes GalaxKing, in most of the games I lost, I find out that I was not calculating much! Some of the moves I gave were only a temporary stall to enemy plans. I have started to use a Stockfish as my game analyzer, and also more careful when I make a move. Just the thing is that the "surprising" crazy moves throw me off my balance at first. And I realized that whenever somebody becomes too aggressive at front, especially in the beginning, I end up becoming excited and making the first move that comes to my mind.
This is not the case when playing with the computer. Here's a game I played just now on chess.com. (The Computer was 2000+).
Yes, I made a mistake in the end and couldn't give it a proper finish (I should have looked for combinations even more!). But do you think it is really that weak?
Let me know what you guys think.
My problem is that when I am playing with real chess players, I am not being able to play my game properly. What's the problem? Well in most cases,the real chess players are giving some "surprise" moves, which are probably not theoretically right, especially in the openings. Result: I am not being able to develop my pieces properly and ending up with a rather bad position. For example, in the Scholar's Mate, I avoid the mate but end up with a hotchpotch. It's like they are putting their pieces in a zigzag manner and I end up with no options than to exchange pieces that would have been important. That's not the end of the story. I play well with a computer though. Even when I am playing with Stockfish 5, I can stand together till the end. It seems that in the beginnings, with too much attack, I am not being able to develop and only defending and thus ending up with a bad position. How to solve this problem? Thanks.