Its main purpose is to train the Afghan National Security Forces (ANSF) and assist Afghanistan in rebuilding key government institutions but is also engaged in the 2001-present war with insurgent groups .