The work energy theorem states that the net work done on an object equals the change in its kinetic energy.
Therefore, in order for the work done on an object to only change the potential energy of object, the net work done on the object must equal zero;
"equal zero" means that no change in kinetic energy and therefore no acceleration causing that change.
In the case of charge, when work is done to move a positive charge between two points in opposition to the force the electric field exerts on the charge, that work only will result in an increase in potential energy if no net work is done on the charge which would cause an increase in kinetic energy.
The process is as follows:
The force exerted by an external agent moving a positive charge is in the same direction as the movement of the charge. Therefore that work done by the agent is considered positive and transfers energy to the charge.
Simultaneously the force on the electric charge due to the field is opposite to the movement of the charge. The work done by the field is therefore negative. In order for the charge to only acquire electrical potential energy the negative work done by the field has to equal the positive work done by the external agent in order that the net work done on the charge is zero. If it were less, the charge would have both potential and kinetic energy.
Bottom line: For there to only be a change in electrical potential energy the field has to take all the energy given the charge by the external agent so that there is no net work done on the charge, and store it as electrical potential energy of the charge electric field system.
The analogy with gravity is external positive work (say done by you) is needed to raise a mass initially at rest on the ground to a point at rest a height $h$ above the ground. Simultaneously gravity (whose force is opposite the motion of the mass) does an equal amount of negative work taking the energy you supplied the mass and storing it as gravitational potential energy in the mass earth system. Since there is no change in kinetic energy of the mass (and thus no net acceleration to cause such change), no net work is done on the mass just like no net work is done on the charge.
Hope this helps.