Four individuals are sitting on a small dock by the water as a boat sails by.
Four people sitting on a yacht.
Four people on a small dock are not on a boat so can not be on a yacht.
You can either be sitting by the water or on a yacht because a yacht will typically already be on the water.
They cannot be sitting be sitting on the dock and the yacht at the same time.