A Common Stochastic Process Rules Gamma-ray Burst Prompt Emission and X-ray Flares