(d) In compression or extension of a spring work is done against restoring force
In moving a body against gravity work is done against gravitational force of attraction
It means in all three cases potential energy of the system increases
But when the bubble rises in the direction of upthrust force then system works so the potential energy of the system decreases