To foster the utilization of regeneration braking energy and suppress voltage unbalance (VU), a railway electrical smart grid (RESG), intergraded with power flow controller (PFC) and energy storage (ES), is proposed as an important part of next-generation electrified railways. However, under the uncertain traction load, how to design the optimal size of PFC-ES is a challenge during the planning period. Hence, this paper proposes a chance-constrained two-stage programming approach. The first-stage aims to minimising the overall cost of RESG's devices. The second-stage aims to arrange the energy flow of the PFC-ES with the objective of minimising the expected operation cost under the dynamic VU restriction, and the stochastics characteristics of traction load are transformed into a chance constraint by using a scenario approach. Then, traction power predictions are combined with multivariate Gaussian Mixture Model(multi-GMM) model to generate correlated traction power flow scenarios and to assess VU probabilistic metrics distribution with different confidence levels. Finally, a novel algorithm is designed to select the confidence level and violation probability so that the capacity planning results can ensure the high-efficient and high-quality operation of the RESG. Case studies based on an actual electrified railway demonstrate that the proposed PFC-Purchased electricity price and penalty charge c dem Electricity price of peak demand power σ l Power loss of converter c bt,uc om,v , c bt,uc om,f Fixed and variable battery or UC daily O&M cost per unit of power rating c bt,uc rep Battery or UC daily replacement cost c bt,uc P Battery or UC daily capital cost per unit of power rating c PFC P PFC daily capital cost per unit of power rating C. Variables P PFC rate Rated power of PFC P bt rate , P uc rate Rated power of battery and UC E bt rate , E uc rate Rated capacity of battery and UC