How to edit audios so that they have the same length
ImageMagick is a great tool to edit multiple images in the command line. Thanks to your question, I just discovered SoX, or Sound eXchange:


  SoX is a cross-platform (Windows, Linux, MacOS X, etc.) command line
  utility that can convert various formats of computer audio files in to
  other formats. It can also apply various effects to these sound files,
  and, as an added bonus, SoX can play and record audio files on most
  platforms.


It can trim, crop, cut multiple files (and resample too), see for instance:


Editing Multiple Mono Sound Files in SoX,
Audio format conversion cheat sheet (aka how to)


For shorter files, an option is to create a silence file, happen  it, and crop again, see for instance: Linux command to extend the duration of audio files.