As it was a castle (or somewhat like one) and the King resided inside, it would be reasonable for there to be guards posted to protect the castle from any intruders. This was common practice and is nothing unusual.
The soldiers want to tell about the ghost to scare you.
guard
It would be normal to have a guard on the king's palace anywhere at any time. But you may be alluding to the fact that a ghost of the dead King Hamlet appears on the battlements every night.
He's a guard, watching the battlements of Elsinore castle to see if the Norwegians are going to invade. He is one of the guards who sees the ghost of King Hamlet in Act 1 Scene 1.
The first characters you meet in Shakespeare's "Hamlet" are the sentinels Francisco and Barnardo, along with Horatio, who is a friend of Prince Hamlet. They are on guard at Elsinore Castle and discuss the appearance of a ghost resembling the deceased King Hamlet. Their conversation sets the tone for the play, introducing themes of uncertainty and foreboding. Hamlet himself is not introduced until later in the first act.
A gate house is a building by a gate of the castle to provide shelter and protection for the gatekeepers. It is often part of the outer wall of the castle. It may actually be a house where the gatekeeper lives or it may be small fort that could be staffed with soldiers.
They tell hamlet.
The soldiers want to tell about the ghost to scare you.
Actually, the word "guard" is a noun already. It can also be a verb. It all depends on how it is used in a sentence. For example, as a verb: The soldiers guarded the supply truck. But as a noun: The guard is standing at the front gate. So, a guard can be a person, or it can describe an action.
guard
Well what i did was shoot the guard and hide behind the vendor thus leaing the guard opening the gate to come attack you
Hamlet
344,346 soldiers
A security guard is posted at the gate of the mental hospital.
The popular name for the monarch's guard soldiers at the Tower of London
Cerberus .
The phrase gives you a visual image of a single tree standing there, which combined with its location at the gate suggests the image of a sentinel or soldier on guard at a gate.