In my opinion they were extremely lucky. The usual advice to stay together and stay with the boat is appropriate in almost all cases (exception noted below).

The article indicates captain had managed to send a Mayday with coordinates. It is very difficult for rescuers to spot people in the water from the air or from another boat, but a group of four people is always easier to spot than one or even two people. Also, even if the boat sinks there will usually be some amount of floating debris that also aids spotting by rescuers. Perhaps had they all stayed together they might have all been spotted sooner?

As noted by hikermor, cold water is also an issue. With a life jacket, by remaining still and huddling in a group you increase your survival time. When swimming, you usually cool quicker. Even though your muscles put out heat from the exercise, you are constantly flushing cold water over your body. The net effect is that in most cases you cool quicker.

Note that "Soon after, they also lost sight of land amid the rain." They could as easily have ended up swimming away from land rather than towards it. Also, even a slight amount of current could have carried them further from their destination.

All in all they were extemely lucky, in my opinion. About the only situation where swimming for land might be the best choice is when there is little or no possibility of rescue. If you are out by yourself, in a seldom traveled area, and left no word with anyone about your plans so no rescue will be launched, then it might make sense to swim for it. Otherwise, staying with the boat is the best plan.

There will always be a few lucky exceptions, but almost always you have better odds staying with the boat.
_________________________
"Toto, I've a feeling we're not in Kansas any more."
-Dorothy, in The Wizard of Oz