Can the military use a military satellite to spy on any place on Earth?
Yes, but only in the absence of clouds. The highest resolution imagery is only available during the day. I strongly suspect they have infrared imagers as well for nighttime imagery, but those inherently have a lower resolution.
In principle, radar or even passive microwave could be used to look through clouds, but the resolution for passive microwave would be much poorer still.
Live?
No. The highest-resolution imagers are in low Earth orbit, so they would have to wait for a satellite to pass. They would also need to programme the imager on where to look, as it cannot look in all directions at the same time / quickly enough to cover everything during a pass (except at much lower resolution, but there are open data satellites such as weather satellites doing that already).
If a military satellite is used to spy on a rival country, can the latter detect it?
They can detect the satellite, but they wouldn't know if it was looking in their direction, nor if it was taking a photo.
If the spy sat uses radar, it would be easy to detect.
is there some technology which can protect a military zone from prying satellites by shielding the area or something
Yes. The technology is called digging. By hiding things underground, they cannot be seen from space or from the air. Other technologies may be camouflage or deception.