This study addresses the growing need for accurate and actionable energy demand forecasting in smart infrastructure systems, where data-driven decision-making is essential for efficiency, sustainability, and system reliability. Despite advances in machine learning-based forecasting, most approaches remain prediction-centric and are rarely integrated with operational optimization and decision-support mechanisms, limiting their real-world applicability. To address this gap, this study proposes a sequentially integrated hybrid machine learning–optimization framework that combines ensemble-based forecasting, optimization-driven energy allocation, and explainable artificial intelligence (XAI) within a unified architecture. The term hybrid denotes the integration of heterogeneous methodological components, while the framework is implemented as a pipeline in which forecasting outputs inform downstream optimization. The predictive module incorporates XGBoost and Long Short-Term Memory (LSTM) models, alongside an ensemble approach that operates within the forecasting stage to enhance robustness and generalization. The optimization component utilizes forecasted demand to minimize energy cost under demand and capacity constraints, while SHAP-based analysis improves interpretability and transparency. Empirical evaluation using the UCI Building Energy Efficiency dataset shows that XGBoost achieves the highest predictive accuracy (MAE = 0.429, RMSE = 0.613, R² = 0.996), while the ensemble model provides strong robustness (R² = 0.994). The integrated framework effectively smooths demand fluctuations, improves allocation efficiency, and identifies relative compactness and glazing area as dominant features. The results demonstrate that sequential integration of forecasting, optimization, and interpretability enhances predictive reliability, operational efficiency, and decision transparency.