In the first hand with AKs I would mainly 3-bet, but its ok to mix in a call now and then. When CO squeeze, I dont hate the backjam, but you could also just have called and maybe gotten away on a board like this, where you missed? At the end of the day a pretty standard "flip" for 40BB, and of course we will win some and lose some.
In the second hand with AQo you only had 3-4BB left, so a very easy spot to get it in, but you dont have any fold
equity this short. If nothing else BB with call you, and against a range of any two cards AQo only has 64% equity. So you will bust here more than 1 in 3 times, and running into aces was of course unlucky but not really important, since you had already lost 90% of your chips in the other hand.