An improving economy made it possible for the mortgage giant to generate $5.10 billion in credit-related gains in 2021.