This study investigates the corrosion inhibition efficiency of three piperazine-based inhibitors (A1, A2, and A3) on carbon steel (CK45) in two aggressive environments: 3.5 wt% NaCl and 0.5 M H2SO4. Unlike previous studies limited to single media, this work provides a systematic comparative evaluation across both saline and acidic conditions, demonstrating that subtle structural modifications in piperazine derivatives drastically alter inhibition performance with A3 exhibiting superior dual-environment efficacy. Electrochemical techniques, including potentiodynamic polarization (PDP) and electrochemical impedance spectroscopy (EIS), along with surface characterization through scanning electron microscopy (SEM) and molecular dynamics (MD) simulations, were employed to elucidate the inhibitors’ performance and adsorption mechanisms. PDP and EIS analyses revealed that inhibitor A3 provided the highest corrosion protection for carbon steel, achieving an inhibition efficiency of 91.0% in 3.5 wt% NaCl and 79.3% in 0.5 M H2SO4 at 2.0 mM, with corresponding increases in resistance to 3855.0 and 2303 Ω·cm2, respectively. In comparison, A1 and A2 showed lower efficiencies (<68%) and smaller improvements in electrochemical parameters, confirming the superior protective film formation and charge transfer resistance induced by A3. Adsorption followed Langmuir isotherms, except A1 in 3.5 wt% NaCl, with negative Gibbs free energies confirming spontaneous and stable adsorption. Surface morphology corroborated inhibitor efficiency, revealing less corrosion and more uniform films in the presence of A3. DFT calculations revealed HOMO/LUMO distributions and energy gaps, confirming stronger Fe(110) interaction and superior adsorption stability for A3 versus A1/A2. MD simulations highlighted stronger chemisorption for A3, with the highest binding energies (293–329 kcal/mol) and lowest diffusion coefficients, reinforcing its superior film stability.