Your problem is tactics, many bad moves in these games, for both players.
Study tactics.
at move 15 your best move was knight f5 taking advantage of the pined piece
and usually when my opponents play that way i castle queenside
Although I haven't looked at the games closely, in game 2 4. Bg5 Qe6 should give you some Kingside space and a tempo
In game 1, castling isn't that great an idea because of how he has a lot of pieces that can attack your castled position very quickly. Just keep your king in the center.
You said...
"...but I noticed that after Qxd5, Bh6 would have renewed the threat of mate at g7 and it seemed that the only way to stop it was to move 10... g6 losing the Rook. So I tried to save the Rook and take the Knight for lost."
What's wrong with trading a rook for both your opponent's bishops? Would've saved your game, and rendered the opponent's attack impotent. The dark square weakness would mean very little with his bishop gone, and the rest of his army sitting quietly on their home squares.
Do the math before you decide on a line.
In a couple of my last games I've lost after my opponents played an early Queen and I couldn't take advantage of having a faster development and of their exposed Queen. The first time, I missed a very simple trap my opponent prepared which put me in some big trouble; the second time, while trying to avoid falling for the same trap, I didn't notice I had weakened my defenses with an earlier move and lost a pawn. Perhaps this last one could have been saved but the next thing I did was a major blunder losing a piece, and I was eventually defeated.
I would like to know what was that I did wrong in this two openings and what's the proper way to defend this attacks and get rid of the annoying Queen. Here are the games in question where I got in trouble (only first moves):