according to wiktionary, they both originate from Arabic اَلزَّهْر (az-zahr, “the dice”). presumably frenchmen were simply wont to add a bunch of silent letters.
https://en.wiktionary.org/wiki/hasard https://en.wiktionary.org/wiki/azar
https://en.wiktionary.org/wiki/hasard https://en.wiktionary.org/wiki/azar
Just like Latin where Spanish "aleatorio" comes from: alea = dice.
Caesar's famous words "alea jacta est" = "dice has been thrown".