Afghanistan is not considered good tank country, but two nations, Canada and Denmark, have deployed several dozen Leopard II tanks there, and found them useful. The 120mm gun provides a quick way to deal with any Taliban fighting from the fortress like compounds common in the region. The tanks were also well protected against roadside bombs and mines. The tanks were also good for recovering other armored vehicles (like the wheeled personnel carriers and MRAPs). The Taliban were also intimidated by the tanks, which proved more robust than the Russian ones their fathers faced in the 1980s.
While MRAPs have become more popular, and plentiful (several thousand are there) because they were lighter, smaller and more mobile on the roads, there were times when the tracks of the tanks could take troops places MRAPs could not reach. Despite those advantages, the United States did not bring in tanks, and the Afghans don't use their Russian models much either. Other nations have brought in some lighter tracked vehicles, and everyone depends on smart bombs (and GPS guided shells and rockets) for heavy firepower.