In Dead Man's Chest, Jack's compass was malfunctioning, and he's indecisive, Tia Dalma correctly guesses that Jack Sparrow either doesn't know what he wants, or knows, but is loath to claim it as his own. Given he was looking for the key to the dead man's chest, he'd probably been thinking about his impending deadline with Davy Jones, which is probably what got him indecisive, but how did that happen? He seems pretty decisive once he gets the black spot; get to land as quick as possible, forget the hat that fell in the water, there's no time to retrieve it
The prevalent theory I see posed online is that he wanted Elizabeth Swann and couldn't claim her because she's Will Turner's, but the compass was malfunctioning well before Will and Elizabeth re-entered the picture, before which he seemed to view them as friends, not particularly pining for Elizabeth as we see with "it would've never worked out between us" and "I want you to know, mate, I was rooting for you", and the compass was working just fine right after that in the first movie. It was already malfunctioning at the start of the second movie, presumably immediately before or after he stole the drawing of the key from that dungeon-prison, my guess is after, right after the compass led him to the drawing, and the crew saying "Has Captain Jack been acting strange....-er?" either indicates he's been tense the whole time leading up to it or was already indecisive for a while by then
The next theory I see tossed around, though rightfully dismissed pretty much immediately, is that he wants to be the Flying Dutchman's captain but couldn't quite decide if he wanted to sacrifice his life on land, but he didn't seem to show any interest in that, nor any knowledge that such a thing would happen, until he was resurrected and broken out of the Locker, see "death has a way of rearranging one's priorities". An argument could be made he was indecisive, and dying finally made him choose, but the compass started to work again once he was about to find the chest, so its contents don't seem to influence the indecisiveness, and pretty much everyone who was looking for the chest planned on using it to threaten Jones rather than replace him
Another answer I've seen is that he desires to sail the seas a free man, continuing to be a pirate, captain of the Black Pearl, and.....yeah, that's probably exactly what he wants, but that's way too broad, the compass points to specific things that work to fulfill your overall desires. It doesn't point to bottles of rum because for a moment Jack's desire for freedom is overridden by his alcoholism, he wants to be a free man and as a free man he wants to drink rum
It's also my pet theory that this is why it points to Jack when Elisabeth uses it, not because she has any repressed romantic feelings towards Jack, she probably likes him a lot but he isn't her ideal man by any stretch of the imagination, it's just that he's good company and has his own sort of charm, similar reasons as anyone else who likes him. And more to the point, he's probably the only person who can reunite her with Will, so the compass is basically saying "stick with Jack, you'll get to Will eventually", which is also why Jack correctly guesses instantly that the chest is buried where Elizabeth is sitting when it points towards her, even if he liked her in that way the compass is pointing towards something useful rather than just broadly gesturing at his desires