Let’s look at what the rule says:
When an inside overlapped right-of-way boat must gybe at a mark to sail her proper course, until she gybes she shall sail no farther from the mark than needed to sail that course. Rule 18.4 does not apply at a gate mark.
Proper Course A course a boat would choose in order to sail the course and finish as soon as possible in the absence of the other boats referred to in the rule using the term. A boat has no proper course before her starting signal.
If yellow at position 3 did not gybe but ventured further out, she would break Rule 18.4.
The second sentence in Rule 18.4 states simply that:
This can be illustrated in example 2 below. Rule 18.4 does not apply because the boats move through a gate mark. At position 2, yellow can decide if she wants to continue on her current course and round the east mark or gybe and round the west mark. Blue, as the windward boat has little to say about it because she needs to keep clear of yellow under Rule 11.
Gate marks are popular in larger fleets as they break up the course and open up technical ingenuity among sailors.
The below scenario is not uncommon and could indeed involve many more boats. However, for the sake of familiarisation, have a look and see if we can sort out the traffic using Rule 18.