Yes, you’re right. On the last hand, South opened 1H which shows just 4 cards in the suit. However, when South rebids 2C (or any 2nd suit) then it shows partner 5 or more cards in Hearts and 4 or more in the 2nd suit. To Open 1H and rebid 2H also shows a 5-card suit.
I didnt understand how North will know that partner has 5 hearts. Doesnt South just need a 4 card major to bid the first time?
Yes, you’re right. On the last hand, South opened 1H which shows just 4 cards in the suit. However, when South rebids 2C (or any 2nd suit) then it shows partner 5 or more cards in Hearts and 4 or more in the 2nd suit. To Open 1H and rebid 2H also shows a 5-card suit.