I'm a bit confused as to why Chechnya and Dagestan stayed a part of the Russian Federation while Georgia, Armenia, Azerbaijan gained independence. Why did the Northern Caucasus remain Russian?
The initial breakup of the USSR was a largely peaceful process prompted immediately by the failure of the 1991 coup against Gorbachev and his liberalizing reforms. Following the coup the Soviet Government was seen as having lost its legitimacy and Gorbachev resigned, handing power over to his Russian counterpart. You see, the USSR was not, strictly speaking, Russia, but a superstate containing a number of Soviet Republics (as evidenced by the name Union of Soviet Socialist Republics), like Ukraine, Kazakhstan, Uzbekistan, Georgia, and Russia itself (called the Russian Soviet Federative Republic).
Upon the collapse of the USSR, each of these direct Soviet Republics declared independence, including Russia proper, which contained a large number of autonomous, non-Russian regions. The independence of the Soviet Republics was immediately recognized by most nations, but Republics like Dagestan and Chechnya were subunits of Russia itself and were not recognized when they declared their own independence almost simultaneously.
In the chaos following the breakup, Chechnya was de facto independent, but in 1994 Russia invaded for the first time and it was viewed internationally as an internal Russian conflict, not prompting international intervention.