In Doctor Who 2005: Big bang 2.0, the Doctor appears with a hat or something and a mop in his hand to rescue himself and Amy Pond after he is sealed shut inside the Pandorica. How can the Doctor come out of the Pandorica to do this? What event triggered this? Is it the act of universe on itself to re-establish the balance to the natural order of events, or is he an entirely new doctor from another time rescuing himself? I did understand everything that happened before and after the Doctor came back in time and gave Rory his sonic screw driver but I am not able to figure out the appearance of the Doctor himself...
The Doctor was rescued because he later came back in time (using the vortex manipulator (the thingy wrapped to his wrist)) to enable his rescue by giving Rory the screwdriver. Thus, he is freed (by Rory with the screwdriver) to come back in time and enable his rescue.
Again, he can only go back in time, because at the time he departs (where he is in the museum, with Amelia, Amy and Rory) he was already freed.
This is commonly called an ontological paradox, although it's a slight misnomer as it isn't actually a paradox; It's just something that cannot be logically traced to an initial cause. The effect causes the cause of itself, that's why we have such a hard time grasping it (which we should as it's fiction).
Doctor Who lore typically resolves this problem by simply calling it wibbly-wobbly timey-wimey and be done with it.
Stable time loops
Yes, it's a paradox wherein the effect is the cause and vice versa. Causality often loops in Doctor Who episodes. As the Doctor himself has said in the past, time is not a straight line from cause to effect. Here, he is able to get out of the Pandorica because a future version of himself comes back in time. And since he gets out, a future version can come back to save him. This is how causality is violated here. This is called a "Stable time loop". He can't get out of the pandorica unless his future self rescues him, and his future self can't rescue him unless he gets out !
There are numerous possible explanations for what constructed the apparent paradox we are shown in the episode.
Closest to the narrative itself, we see that the pandorica itself exists in close proximity to the TARDIS explosion that broke the universe, and the incongruity can be explained away by simply realizing that by this point time is already kinda broken.
Going a bit further afield, we could instead assume that there is an aborted timeline we were not shown, in which river pilots the tardis without the doctor and crashes, or sets up the stable time loop, or even a pair of such. The Tardis itself could also have exerted some effort.
And, of course, if you are willing to go even further afield, such actors as the church of the silence or the moment could have played a part as well. (the latter being more likely, but I'm endeavoring to avoid potential spoliers.)
When the doctor is out of viewer site and alone, we, the audience can't assume that he/she isn't time travelling outside the particular time-line which we are viewing in the episode. While all the characters are up above ground, there was nothing stopping the doctor from using River's vortex manipulator to do a bid of time travel. The doctor could have time travelled anywhere/anytime to set-up the rest of the time-line for the episode. He returns the vortex manipulator back to River which I suspect is a hint that there's an explanation, but we, the viewers, just haven't figured it out.....