Exploring Phase Transitions in Magnetic Systems through Monte Carlo and Machine Learning Techniques