Projections suggest narrow win for Olaf Scholz’s party, fending off the AfD and offering respite for embattled chancellor