Why are "counterweights" used in aircraft production?
In the context of aircraft design and maintenance, the terms counterweight and ballast generally have separate and different meanings.

Both concepts involve mass used to balance, dampen, or adjust forces about a rotational axis. While ballast could also be described as a type of counterweight, it is best understood as working within the frame of reference of the entire aircraft since it adjusts the aircraft Center of Gravity (CG). Conversely, counterweights can be understood to work within a frame of reference that is smaller than the aircraft as a whole, such as an engine or a control surface.

I will address each separately.

Counterweights

Counterweights primarily serve three functions in aircraft design: balancing control surfaces, controlling propeller pitch, and balancing crankshafts in piston engines.

Control Surfaces

Counterweights are used to balance control surfaces about the axis of the hinge to avoid potentially dangerous control flutter. This balance is very important. Pilots typically check for counterweight structural security in preflight where able. Mechanics must recheck control surface balance after painting, and painting control surfaces is excluded from the list of preventative maintenance items that an aircraft operator can perform without a mechanics license.

From the A&amp;P Mechanics Airframe Handbook AC65-15A:


  It is this out-of-balance condition that can cause
  a damaging flutter or buffeting of an aircraft and
  therefore must be eliminated. This is best accomplished
  by adding weights either inside or on the
  leading edge of the tabs, ailerons, or in the proper
  location on the balance panels.


The following excerpt from the Cessna 172M IPC shows the elevator counterweights, 23, highlighted in blue:



Propellers

Counterweights are used in some constant speed propeller designs to increase the pitch of the propeller blades. Engine oil pressure is used to overcome the force of the counterweights to move the propeller blades back to fine pitch. In feathering designs, the counterweights assist in moving the blades to the feathered position.

From the A&amp;P Mechanics Powerplant Handbook AC65-12A:


  Propellers, having counterweights attached to the blade clamps,
  utilize centrifugal force derived from the counterweights to increase
  the itch of the blades. The centrifugal force, due to rotation of the
  propeller tends to move the counterweights into the plane of rotation,
  thereby increasing the pitch of the blades.





  Feathering is accomplished by releasing the governor oil
  pressure, allowing the counterweights and feathering spring to feather
  the blades. This is done by pulling the governor pitch control back to
  the limit of its travel. which opens up a port in the governor
  allowing the oil from the propeller to drain back into the engine. The
  time necessary to feather depends upon the size of the oil passage
  from the propeller to the engine, and the force exerted by the spring
  and counterweights.


AC65-12A Fig 7-11:


Crankshafts

Counterweights are used in piston engines for both static and dynamic balancing.

From the A&amp;P Mechanics Powerplant Handbook AC65-12A:


  Crankshaft Balance
  Excessive vibration in an engine not only results
  in fatigue failure of the metal structures, but also
  causes the moving parts to wear rapidly. In some
  instances, excessive vibration is caused by a crankshaft
  which is not balanced. Crankshafts are balanced
  for static balance and dynamic balance.
  A crankshaft is statically balanced when the
  weight of the entire assembly of crankpins, crank
  cheeks, and counterweights is balanced around the
  axis of rotation. When testing the crankshaft for
  static balance, it is placed on two knife edges. If
  the shaft tends to turn toward any one position during
  the test, it is out of static balance.
  A crankshaft is dynamically balanced when all
  the forces created by crankshaft rotation and power
  impulses are balanced within themselves so that little
  or no vibration is produced when the engine is operating.
  To reduce vibration to a minimum during
  engine operation, dynamic dampers are incorporated
  on the crankshaft. A dynamic damper is merely a
  pendulum which is so fastened to the crankshaft that
  it is free to move in a small arc. It is incorporated
  in the counterweight assembly. Some crankshafts
  incorporate two or more of these assemblies, each
  being attached to a different crank cheek. The
  distance the pendulum moves and its vibrating frequency
  correspond to the frequency of the power
  irnpulses pf the engine. When the vibration frequency
  of the crankshaft occurs, the pendulum oscillates
  out of time with the crankshaft vibration, thus
  reducing vibration to a minimum.
  
  Dynamic Dampers
  The construction of the dynamic damper used in
  one engine consists of a movable slotted-steel counterweight
  attached to the crank cheek. Two spoolshaped
  steel pins extend into the slot and pass
  through oversized holes in the counterweight and
  crank cheek. The difference in the diameter between
  the pins and the holes provides a pendulum
  effect.


From the Continental O-300 overhaul manual:


  C-145 and 0-300 crankshafts have a blade extending from each side of the cheek between No's 1 and 2 crankpins for attachment of dynamic damper counterweights. Each blade has two holes bored through and steel bushed. Slotted counterweights fit over the blades and have holes bored through and bushed to match those of the shaft. Bushings are sized to produce the desired frequency.


The following shows those counterweights on an O-300 crankshaft that is apart for overhaul:


Source: own work



Ballast

Ballast provides a temporary or permanent change to overall aircraft center of gravity. Ballast might be included as a permanent part of an initial or modified design. When I was in flight training we used old aircraft tires filled with concrete as ballast to place the W&amp;B of a U206G near a max gross weight and aft CG configuration for portions of mountain flying training.
I know glider pilots use ballast for adjusting aircraft CG as well.

From the A&amp;P Mechanics General Handbook AC65-9A (this AC is cancelled, but this comes from my old print edition and is still accurate):


  Ballast is used in an aircraft to attain the desired c.g. balance. It is usually located as far aft or as far forward as possible to bring the c.g. within the limits using a minimum amount of weight. Ballast that is installed to compensate for the removal or installation of equipment items and that is to remain in the aircraft for long periods is called permanent ballast. It is generally lead bars or plates bolted to the aircraft structure.





  Temporary ballast, or removable ballast, is used to meet certain loading conditions that may vary from time to time. It generally takes the form of lead shot bags, sand bags, or other weight items that are not permanently installed.