Undercut explained! Undercutting is basically overtaking by strategically pitting and by doing so coming out ahead of the other.
1: Imagine, Hamilton is driving 1st, Vettel behind him. They're driving the same pace, with a 3 second gap. Laptime, let's say 1.04,000. Vettel pits, to make it less confusing, it's just added as an additional 20 seconds, without having the in- and outlap. Result is the same: pitstop costs 20 seconds. The gap now grows to 23 seconds. But with fresh tyres, Vettel is able to put in quicker laptimes: 1.02,000, 2 seconds quicker than Hamilton still on his old tyres. Difference 2 seconds, gap reduced to 21 seconds.
2: One lap later, Vettel gains 2 seconds again, reducing the gap to 19 seconds. Mercedes realises that Hamilton should pit, so he pits and that costs him 20 seconds. This reduces the gap to Vettel with 20 seconds.
3: But on his fresher tyres, Vettel had already reduced the gap to 19 seconds. Which means that Hamilton will come out of the pits 1 second behind Vettel. They can drive the same pace after that, but those 2 laps in which Vettel gained 2 seconds every lap he had fresher tyres, made the difference. An overcut is Hamilton still coming out ahead of Vettel, so basically holding position. This can be done by pushing hard those last laps when Vettel just got new tyres.
So that's how an undercut is done. It's a strategic move of the team, so Ferrari might be not the best team to use this as an example, but anyways, this is how it works.