One simple reason is both Azerbaijan and Armenia have fought two fairly bitter wars against each other. There was the Armenian-Azerbaijani War of 1918-1920 which largely emerged out of two newly independent states/peoples trying to draw boundaries over territories they both claimed as theirs. Then the Soviet Union absorbed both and that was the end of that conflict.
Then from roughly 1991 to 1994 (depending on what you count as being part of the war) you have the Nagorno-Karabakh conflict. Again this was a fight over both sides claiming the same real estate, in this case Nagorno-Karabakh/Artsakh. This map will give you some idea of the political geography between Azerbaijan and Armenia. Keep in mind within those borders were smaller enclaves of Armenians and Azeris living on the 'wrong' side of the border, making even those already convoluted borders too simplistic.
Prior to this in the late 1980s there were also a number of incidents of inter-ethnic violence between the Armenians and Azeris, such as the Sumgait Pogrom (1988). Soviet troops intervened in these conflicts, but these actions tended to be heavy handed and just lead to more dead people and anger, particularly as some were perceived as (and possibly were) in support of one side or the other. So Black January in Baku for the Azeris and Operation Ring for the Armenians.