Algorithmic fairness with optimal transport: quantifying counterfactual fairness and mitigating group fairness