Mechanisms of granular spontaneous stratification and segregation in two-dimensional silos