Abstract This study conducts a meticulous examination of the cosmological implications inherent in Rastall gravity and $f(R)$ gravity models, assessing their efficacy across distinct cosmic epochs, from early universe structure formation to late-time acceleration. In the initial stages, both models exhibit commendable compatibility with observed features of structure formation, aligning with the established $\Lambda$CDM model. The derived Jeans' wavenumbers for each model support their viability. However, as the cosmic timeline progresses into the late universe, a discernible disparity surfaces. Utilizing the Markov Chain Monte Carlo method, we reconstruct the deceleration parameter $(q)$ and identify Deceleration - Acceleration redshift transition values. For $f(R)$ gravity, our results align closely with previous studies, emphasizing its superior ability to elucidate the recent cosmic acceleration. In contrast, Rastall gravity exhibits distinct redshift transition values. Our rigorous analysis underscores the prowess of $f(R)$ gravity in capturing the observed cosmic acceleration, positioning it as a compelling alternative to the conventional $\Lambda$CDM model. The discernible shifts observed in the peaks of the CMB power spectrum and evolution of deceleration parameter (q) for both $f(R)$ gravity and Rastall gravity models in the Early and Late universe, in relation to the $\Lambda $CDM model, provide compelling evidence supporting the proposition that these alternative gravity models can account for the anisotropy of the universe without invoking the need for dark energy.