Compasses are fascinating things, with much to teach for being an inanimate object. I’m speaking of course, of an analog piece, little changed for centuries, not the app on your phone.
There can be a number of things that affect the proper reading of a real compass, causing one to lose direction. Unlike your phone, a dead battery isn’t one of them.

Other things in your pocket may be interfering, pulling the needle from true. Take this as a sign that you may have too many things in your pockets, and that it might be time to simplify. Don’t let other things confuse your compass and cause you to lose direction. True direction is the highest priority.
It seems inevitable that cheap compasses develop bubbles over time. These too will affect the needle. Don’t trust your life, whether it be your ultimate safety or only your current direction, to cheap things. You’ll get exactly what you paid for.
Compasses are only useful when you can see them, and the less accessible they are, the less likely you are to use them. Keep your compass handy and refer to it often.
There is an old adage to the effect of, “if you keep checking your course regularly, it’s much harder to get lost than if you wait until you’re not sure where you are.”
Sage advice.