The Mavericks hung on, snapping Dallas’ four-game losing streak, behind huge nights from Cooper Flagg and Klay Thompson.