The 'tragedians of the city', professional actors, appear at exactly the opportune moment in Act 2, just as Hamlet wouldl like to see them. Yet they, and their performance of 'The Mousetrap' (as adapted by Hamlet himself) are by no means the only meta-theatrical or theatrical constructs within the wider play.
As the veteran critic Anne Barton has commented, 'the stage imagery of Hamlet... is there from the beginning, and it remains important in the final movement of the tragedy. The ghost of Hamlet's father comes in the 'shape' or 'form' of the buried majesty of Denmark, as though he were an actor in a doubtful part. Alarmingly, this may be exactly what he is: an agent of hell impersonating the dead King. Hamlet himself, after having contemptuously repudiated those 'actions that a man might play' on his first appearance (I.2.84) confronts this ambiguous ghost, decides that henceforth he will play the part of madman, and proceeds to devise a lethal little dramatic entertainment in which to 'catch the conscience of the King'... He is conscious again of the playlike character of events when, at the very end, he addresses the silent and horrified court of Denmark as 'mutes or audience to this act' (V.2.329)'
Why is Hamlet obsessed with theatre images? Because, of course, Denmark is the land where one can "smile and smile and be a villain". Everyone is fake, everyone is playing a part, everyone is an actor. No-one can be believed: appearances are always deceptive. And Hamlet's love of theatre (as we find when he talks about the actors to Rosencrantz and Guildenstern) provides the perfect escape, metaphor and key with which to understand a fundamentally pretend, lying court.
The first line of Hamlet is "Who's there?" It's a question you can ask of almost every character: who is the actor, and who the real person? What is really going on?