There are essentially three things that you might be trying to do with an overcall: guide the defense, show values, and get in the opponents' way. You're generally not trying to do all three things every time.
With something like AQJxx x xxx xxxx
, you're telling partner where you live. You'd like a spade lead (especially from a holding of Kx or Tx, which aren't usually attractive holdings to lead from), and you wouldn't be terribly upset to find yourself declaring 2 or 3 spades against opponents' partscore, possibly going down one into their +140. If partner takes some strong action, you will take whatever the weakest action is at your turn to bid.
With this hand, when partner has an average hand, the hand belongs to you. You have a fairly offensive hand, but you still have some defense. Again, you would be happy to declare a partscore in spades, but you're also willing to defend or even make it to game if partner has a suitable hand. You wouldn't be thrilled to see partner lead the SK, but it probably won't destroy the defense. If you pass, partner won't think you have values this good and a 5-card spade suit.
This overcall is especially attractive over 1C. 1S preempts responder's most likely call of 1H, and if the auction continues (X)-2S, opener will not know whether responder has good values or good hearts (or neither). The call is somewhat less attractive over a 1D opener (although your diamond honors would be well-positioned in that scenario), but still attractive over 1H, because you want your partner to compete with a spade fit. If you swapped your majors, 1H is less attractive because your spade doubleton suggests that you'll lose any partscore battle, but it's still worth getting in there because of the values.
Note: If you rearrange the suits so that you hold Ax KJxx QT9xx Tx
, this is not nearly good enough to overcall 2D over 1S, but still worth 1D over 1C.