German Chancellor Angela Merkel has been re-elected while nationalists the AfD have won seats for the first time.