The acceleration of charged particles and formation of power-law energy spectra in nonrelativistic magnetic reconnection