A trace formula for functions of contractions and analytic operator Lipschitz functions