Regarding why this happens, a possible reason is the ruin process. See the following related discussions:
Regarding how to resolve this, an elegant way is to implement a custom ruin strategy to make sure that, when the ruin phase ends, you will not have two “delivery” activities in a row.
A workaround would be to implement a soft activity insertion constraint to encourage the insertion of a non-“delivery” activity between two “delivery” activities.