In both games tactical mistakes were your main problem. As just a few examples:
Game 1
15 … Rxb3 loses a rook for only a pawn
20 … Nd2 forks the queen and rook (good spot!) … unfortunately, it could have been captured by the B on h6.
36 … Qxd2 you had a strong attack going here, the exchange of queens pretty much ends it. You still have material advantage, but white’s pieces are a bit more active and can threaten to pick off your pawns pretty quickly.
39 … Rxb2 loses your N.
Game 2
16 … Bf4 loses it to exf4
17 … Bxe3 is the same mistake
Study tactics, tactics, tactics. Then study tactics a bit more.
At a more positional level, in Game 1 12 … g5 was a serious mistake. This move opens up a big hole in the defenses around the king. In fact, white exploits this hole to win in the end. Think long and hard before moving a pawn in front of castle king. That move will create a weakness, you need to get something good in exchange. 17 … g4 makes the problem worse.
In Game 2 after 32 Nxb7 the danger here is that white will pick off the other pawn and then have a clear path to advance their a and b pawns to queen. Which is what happened. You needed an active plan to stop this. One plan would be advancing you king-side pawns, forcing white to defend against this threat (instead of advancing their own pawns).
Im my last two games I got advantage in the endgame but I manage to mess it up and I lost both games.
How can I get better at the endgame?
It is not only about how I lost those game but more about why I didn't win.
One game from around move 26 I was playing black and I think I had massive advantage...
https://www.chess.com/analysis/game/live/5901078403?tab=analysis
Game two https://www.chess.com/analysis/game/live/5900808880 black again from around move 28...