Friedrich Merz, the frontrunner to become chancellor in February's election, caused an uproar by agreeing to work with the far-right AfD on immigration measures.