Depending on the effective stack size, positions and action its sometimes correct to stack off with both AQ and AK preflop, and other times not. AK of course more often than AQ and the suited versions more often than the offsuit ones.
Example 1
Its a tournament, and you are sitting with 18BB in CO. MP makes a raise to 2,2BB, you rejam with AQo, and he call. MP flip over AA and bust you from the tournament. This is just a cooler. You did, what you are supposed to do, and you just happened to run into the top of his range. This is part of the game and happen to everyone.
Example 2
You are playing a full ring cash game and open AKo from UTG to 2,5BB with a 100BB stack. UGT+1 3-bet to 9BB, and now UTG+2, who is a tight player, comes in for the cold 4-bet and makes it 25BB. Both players have you covered. You jam, UTG+1 fold, and UTG+2 call. UTG+2 flip over AA and stack you. In this example you overplayed your hand. Given the action, which is all in early position, there is a very high risk, that UTG+2 has exactly AA or KK or at best maybe QQ or another AK. You only had 2,5BB invested in the pot, so you should have folded and saved yourself a lot of chips.