Germany came from behind twice to draw 2-2 against Hungary and book a place in the last 16 of Euro 2020 in a thrilling encounter.