Sometimes you realy can't avoid it
It realy depends what type of game you are playing if it's super turbo or turbo where you are < 10 BB i guess shoving PF is the right play. If you have no information about your player and you have 20BB in a fast pace game i don't think you can avoid an all in either because of the 5-7BB PF raise.
Tournament play and Cash games differ a bit
I feel like a bet 5-7BB is bad in tournament but it feels ok in cash game. But in cash game it's alot easyer to avoid getting allin with top pair. I do fold more top pairs on cash game because i have the time to gather all information of the player before making tricky decisions. And in cash game its easyer since you normaly have a bigger stack like 200BB stack and can do things like check raise to test players and gather information.
[Tournament]Try to be transparent
Try to be transparent so that when you have KK or 89 they can't know what hand you have.
You basically tell him which hand you have by doing a 5-7BB raise PF. Hands he will expect from you AJ+ and TT+. If you think about it yourself, do you realy raise 5-7BB with JTs or stuff like 89 ? I don't think so, and even if you did than it's either early tournament or you should start changing up your betting pattern PF.
The fact that you raised 5-7BB i guess blinds where at 50/100 and you had something like 5k stack. At that point bad players tend to gamble alot because its early tournament and if there's a rebuy still going on they won't hesitate. At later blinds like 500/1k people have around 20k so they won't risk calling 5-7k to see if they hit trips, they would rather go for an all in or fold with low pairs.
[Tournament]Player tendency
Players limping and calling those kinds of bets often have pairs or suited connectors. If you are playing Tournament and blinds climb up slowly(12min) you should be at 50BB stack and with that in mind you shouldn't try to risk your whole stack on a single play against someone you have no information at all(unless you feel like gambling).
Analyze your opponent:
Biggest mistake new players make is that they always focus on a single hand they played when they should focus on all the hands they played against their opponents.
If you gather enough information about him you can read your opponent easly. Often it only needs one hand to know what kind of player he is.
Situations like going all in UTG with 20BB with something like A5 you would recognize that this player is realy bad and you could write some notes about it.
You should learn his betting pattern and if he often checks out of position when he has a hand or if he bets when he has a hand. Often bad players tend to do the same thing over and over so keep writing notes (i feel like writing notes more useful than HM and PT) and have your Holdem manager or Pokertracker tracking all that usefull information. You could check the time they take before betting you might get some tells out of some people. Every single piece of information is important so try to write them all down.
If you play 1 tournament at a time it might be boring but if you track all the information you won't have time to be bored and you will get further in a tournament and avoid some of those tricky spots.