How can depletion region be formed at the center? Let's consider an electron at the junction in the n-type region. As it moves into the p-type we say it leaves behind a positive ion and hence in this way electrons at the junction in the n-type create a positive space charge region. But as an electron (at the junction) moves into the p-type, its position would be occupied by another electron waiting at the back (because all the electrons are in random motion). 
So if we see in this way ultimately a positive space charge would be developed at the surface of the n region.
so whats wrong with my understanding?
 A: There is nothing wrong in your understanding. You are simply not extending it, that is how does the depletion region behave when it as grown sufficiently large?
In a PN junction, there is a majority of electrons at the n-side and holes at the p-side. Due to this concentration gradient, the electrons (say, E1) start diffusing into the p-side (leaving behind a bound positive charge). Similarly, the holes (H1) also start diffusing into the n-side, leaving behind a bound negative charge. 

But as an electron (at the junction) moves into the p-type, its
  position would be occupied by another electron waiting at the back
  (because all the electrons are in random motion).

Yes, the electrons behind E1 (say, E2) would occupy the frontal position, leaving behind positive ions at their own (E2) position. However, this motion is not because the electrons are moving randomly but because they are trying to reduce the concentration gradient. This motion of charges is also known as diffusion current ($I_{d}$).
Now, since the gradient still persists, these electrons (E2) would then enter the p-side, again leaving bound positive charges. While the next layer (E3) occupies the initial position of E2 and the process carries on. A similar process occurs due to the motion of the holes - leaving bound negative charges in the p-side of the junction. Thus increasing the depletion region.


So if we see in this way ultimately a positive space charge would be developed at the surface of the n region.

No, the space charge does not keep increasing infinitely. 
As the depletion region grows, a potential difference is created due to the bound charges, leading to the formation of an electric field inside the region. This electric field pushes electrons from n-side towards the p-side and holes from p-side towards the n-side (thus opposing the diffusion current). In fact, the larger the depletion region, the stronger is the electric field and consequently the drift current ($I_{s}$). 
At a sufficient width (of the depletion region), equilibrium is achieved, as the diffusion current ($I_{d}$) equals the drift current ($I_{s}$), hence the net current in the PN junction tunes down to zero. 
Now, since the depletion region was growing due to the motion of majority charge carriers (i.e. diffusion current), the depletion region consequently stops growing. 
In reality, the width of the depletion region (in equilibrium) is generally in the range of micro-meters. 
