How to generate an automatic bash/script
You need to process each mp4 file individually:

cd folder_2
for m in *.mp4; do
    a="${m%.mp4}".avi
    if [[ -r "/path/to/folder_1/$a" ]]; then
         echo touch -r "/path/to/folder_1/$a" "$m"
    fi
done


Run once to verify that the generated output makes sense, then remove the echo and rerun.

PS: This assumes that the names of the video files don't contain the string ".mp4" as such.