Going all-in preflop can be both correct and incorrect depending on stack sizes, positions, action and of course your exact hand. We are always very happy to get it in preflop with AA, because preflop thats the nuts, but even with KK it can sometimes be better to not put in the extra raise and just call, or even in rare situations fold, if it seems highly likely, someone else have AA.
Moreover raise sizes should always be in relation to the size of the pot and remaining stacks. So even if any raise preflop with AA is always profitable, its not optimal to pile in 100BB over a 3BB open. So dont be afraid to see flops with premium hands. Postflop big pairs are just hands like any other, and you make decisions based on, how the board runs out and the action of the opponent.
Maybe one tip, that can help you, is to stop thinking at the situation like "I have JJ" or "I have AA", but instead think of it as "I have an overpair on a dry board", or "I have top set" or "I have an underpair to top pair". Or in broader terms "I have a value hand" (overpair), "I have a strong value hand" (top set), or "I have a marginal made hand" (underpair to top pair).
If you have


on



, your situation is not all that different from having


on the same board, and your plan should generally be to do some pot control and try to get to showdown in a small to medium sized pot. Unless of course you improve, in which case you make a new plan.