to keep close watch over something and guard it: to protect it, hold onto it faithfully, or keep it safe
At its core this verb pictures someone keeping vigilant watch over what matters most. The same act of guarding shows up everywhere the word is used: a gardener watching a vineyard or a fig tree, a soldier holding a fortified position, God shielding a faithful person from danger, a worshiper holding fast to a command, and a wise person standing guard over their own heart and tongue. In each case something valuable is being watched and kept.
The senses below are not separate words but one idea pointed in different directions. Guarding a vineyard, preserving a life, and keeping a commandment are all the same posture of attentive care, applied to a wall, a person, or a promise. That is why the word can slide so naturally from a literal watchman to an inward one without ever changing its meaning.
The word lives almost entirely in poetry, especially the Psalms and Proverbs, where its favorite objects are personal and inward: the heart, the mouth, the way, wisdom, and above all God's instruction. By the time of Psalm 119 it has become one of the standard words for treasuring and obeying God's law. Watching over a city wall and watching over your own heart turn out to be the same word doing the same thing.
The one place the picture turns dark is when the watchers are hostile. A besieging army keeping close watch on a doomed city, or invaders set against it, are described with this same verb: close attentive watching can serve a friend or an enemy, and only the situation tells you which.