Literary critics consider Hamlet to be one of Shakespeare's most "self-reflexive" plays, which is to say that Hamlet self-consciously refers to the workings of the theater and also draws the audience's attention to the fact that the play is a theatrical production. In the play, Hamlet frequently takes on various theatrical roles (he famously plays an "antic," tries on the role of a typical "revenge hero," and so on), which allows the play to explore ideas about human nature and character. Shakespeare's also interested in contemplating the power of the theater. When Hamlet organizes a group of traveling players to perform The Murder of Gonzago (a.k.a. The Mousetrap), a play that mimics Claudius's murder of Old Hamlet, he hopes that such a device will reflect the truth or, "hold a mirror up to nature."
In Hamlet, theater is exactly what Hamlet says it is: a faithful reflection of what is going on in the world.
Hamlet himself defines theater as an art designed to "hold, as 'twere, the mirror up to Nature" (3.2.1). But in Hamlet, Shakespeare presents theater as something that shapes reality, rather than merely reflecting it.