When and How: Learning Identifiable Latent States for Nonstationary Time Series Forecasting