Why both ICAO and IATA headquarters are located in Montreal?
ICAO is headquartered in Montreal because that was the result of a vote by the founding members (PICAO is Provisional ICAO):


  Why was Montreal selected? While insisting on the excellent
  hospitality offered since of the beginnings of PICAO by the federal,
  provincial and municipal authorities, the delegates described Montreal
  like a roundabout of the international means of communication and a
  strategic centre with a formidable economic, scientific, technical and
  aeronautical expansion being felt for a few years. One insisted on the
  vast spaces of the Canadian territory, offering unlimited
  possibilities for the scientific and practical experiments in the
  field of aviation. Moreover, PICAO was to be established as close as
  possible to the central head office of the United Nations.


And IATA is in Montreal because its founding statutes said that it must be in the same location as ICAO:


  Article II of the IATA 1945 Statutes states that “The Head Office of
  this Association shall be maintained in the city in which the
  headquarters of the International Civil Aviation Organization is
  located.”; this article was later amended to leave an opening for a
  possible other place as determined by the General Meeting