I think you should use something like the following loop:
for NAME in *.mkv
BASE=$(basename $NAME .mkv)
mkvextract tracks $NAME 1:$BASE.avi 2:$BASE.ogg
You can probably figure out how to complete the loop yourself. During each cycle, the current file's name can be referred to as $NAME (which ends with ".mkv"), and $BASE is the filename with ".mkv" removed.
Here I assume that the .mkv files are located in your current directory and the filenames don't contain space characters.