If you're looking at this from a technical sense, the enclaves and enclaves technically don't exist anymore as a result of the Artsakh War in the 90s and are only there due to political reasons. Technicalities aren't fun so to understand the full history you have to look at the events of the last century or so. There are several exclaves and enclaves The larger ones, Nakhechevan (both controlled by Azerbaijan) and Nagorno-Karabakh (Controlled by Armenia and called Artsakh. The smaller ones, Arstvashen (controlled by Azerbaijan), Tigranashen, Askipara, Sofulu and Barkhudarly (all four controlled by Armenia). Here is the thing, all of these enclaves and exclaves were owned by the First Republic of Armenia (1918-1920) after it broke away from the Transcaucasian Republic (lasted 6 months) which became independent from the Russian Empire. Nakhechevan, Artsakh and the other smaller exclaves and enclaves were owned by Armenia with Artsakh having a population that was 90% Armenian and Nakhechevan was split nearly 50/50 (now with almost no Armenians as they have been deported) in terms of population between Armenians and Muslims (the Muslims living there were not necessarily Azeri).
During the existence of the First Republic of Armenia, wars between Azerbaijan, Georgia and Armenia ensured that border conflict would remain unsettled after the Bolsheviks took control of the area. While power in Transcaucasia was being consolidated by the Bolsheviks, these areas had originally been designated as Armenian by the Bolshevik Caucasus Bureau in 4 July 1921; however, the next day this decision was revoked by Stalin, without deliberation or a vote, in his power as the Commissar for Nationalities and they were handed to Azerbaijan throughout the next decade or so (my theory is that these lands were handed to the Azeris in a way for Stalin to appease Ataturk and try to win Turkey over as an ally as Stalin cited Article V of the Treaty of Kars (1921) which stated "The Turkish Government and the Soviet Governments of Armenia and Azerbaijan are agreed that the region of Nakhchevan, within the limits specified by Annex III to the present Treaty, constitutes an autonomous territory under the protection of Azerbaijan"). These lands were given to Azerbaijan (as well as some lands in North Armenia being given to Georgia) while the three republics were united as the Georgian-and-Azeri dominated Transcaucasian Socialist Federative Soviet Republic (1922-1936) or more simply the TSFSR. So on 7 Julu 1923, the TSFSR established the Nagorno-Karabakh Autonomous Oblast within the borders of Azerbaijan and on 9 February 1924, the Soviet Union officially established the Nakhchevan ASSR It should be noted that the transfer of Armenian territories to Azerbaijan and Georgia were made without taking into consideration the position of Armenian authorities.
As part of the USSR, the Ghazakh district of Elizavetpol province was divided between Dilijan province of Soviet Armenia and Ghazakh district of Soviet Azerbaijan, with the border issue still unresolved. The Ghazakh district covered almost the whole territory of today’s Tavush province and the territory lying to the north of Chambarak village of Gegharkunik province, as well as Artsvashen (in 1920 referred to as Bashgyugh, or Bashkend) with its surroundings. At that, together with Artsvashen, the area stretched around Tavush River’s Akhnja branch headwaters and the territories adjacent to the left bank of Asrik River upper current. (The territory stretched from Artsvashen and Ttujur pass to the eastern border of present day Tavush province, i.e the territory of about 250 square kilometers lying to the east of Chinari village). The situation in Tavush was tense, with the continuing conflict between Armenia and Azerbaijan not only for control over the territory but also for the use of agricultural lands and forests.
The Transcaucasian Central Executive Committee formed a commission dealing with the territorial disputes and resolving them exclusively against Armenia. The so-called exchange of territories was carried out one-sidedly at the expense of Armenia, giving part of them to Azerbaijan and some to Georgia. Thus, in January 1927, the territory of about 12 thousand hectares from Bashkend to Dilijan was ‘gifted’ to Azerbaijan’s Ghazakh district. As ‘compensation’, in February 1929, under the Central Executive Committee’s decision, Armenia got a connection with Arstvashen through a strip of land, which was however, given to Azeris in 1930s, making Artsvashen Armenia’s exclave in Azerbaijan.The wedge-shaped Lower Askipara (variant of Armenian name Voskepar) lying between Ijevan and Noyemberyan was also a part of the First Republic of Armenia. In 1920, this territory including the neighboring villages of Baghanis-Ayrum, Ghushchu-Ayrum, Mazam and Kheyrimly was transferred to Azerbaijan, which also wanted to get the area of Upper Askipara situated to the west of Armenia’s Voskepar village. The exact date of the Tigranshen enclave's creation is not known either. However, some sources as well as administrative maps show that it was cut from Armenia and transferred under control of Nakhchevan (now autonomous within the Soviet Republic of Azerbaijan) in late 1940s.
Sources:
Readings on the Bureau of the Caucasus
“Territorial Losses of Soviet Armenia and Nagorno Karabakh Autonomous Oblast in 1920-30s”, authors Karen Khachatryan, Hamo Sukiasyan, Gegham Badalyan, Institute of History at RA Academy of Sciences, Yerevan 2015.
Charlotte Mathilde Louise Hille (2010). State Building and Conflict Resolution in the Caucasus. BRILL.
"Contested Borders in the Caucasus : Chapter I (2/4)". Poli.vub.ac.be. Retrieved 14-1-2019.