Particle acceleration is a fundamental process in many high-energy astrophysical environments and determines the spectral features of their synchrotron emission. We have studied the adiabatic stochastic acceleration (ASA) of electrons arising from the basic dynamics of magnetohydrodynamic (MHD) turbulence and found that the ASA acts to efficiently harden the injected electron energy spectrum. The dominance of the ASA at low energies and the dominance of synchrotron cooling at high energies result in a broken power-law shape of both electron energy spectrum and photon synchrotron spectrum. Furthermore, we have applied the ASA to studying the synchrotron spectra of the prompt emission of gamma-ray bursts (GRBs) and pulsar wind nebulae (PWNe). The good agreement between our theories and observations confirms that the stochastic particle acceleration is indispensable in explaining their synchrotron emission.