Purpose of capacitor across transformer in AC-DC power supply?

Yes the yellow thing is a transformer, since it is used at a much higher frequency than 50 or 60 Hz mains, it can be much smaller.

Isolation is indeed very important. A user must be able to safely touch the secondary (5V) side without feeling a thing.

The optocoupler senses the output voltage and feeds back a signal that tells the input (mains voltage) side if the output voltage is too high or too low. This is called feedback.

C5 is required ! It is needed to provide a path for high frequency signals caused by the switching of the input side DC voltage. This switching is what makes the DC at the input side into AC, which is transformed to a lower voltage and then rectified again and smoothed by a capacitor. Note that C5 needs to have a very high voltage rating. Imagine what would happen if C5 broke, became a short and then you touched the output.

The black transformer at the input is a common-mode suppressor. It attenuates (filters) unwanted signals generated by this supply and tries to not let them escape from the mains side. Without this common-mode suppressor the supply will still work but it might not meet EMI requirements.

Important last remark: Do NOT buy the cheaper one without the common-mode choke and the worse isolation !

Looking at it, I think it has no isolation at all ! It is not suitable for making a safe 5 V supply from mains voltage. It would only be OK-ish in an isolated box where it is impossible to touch any the wires and which has no connections a user can touch.

  1. Question 0 Yes, the yellow part is transformer, actually "the transformer" the one that does the job i.e. scales the voltage from mains 240V to something about 20V. The black transformer is common-mode suppressor - you see, the voltage coming out of the mains is very nasty and combined with the low quality and high coupling of this circuit will be very unsymmetrical. The black transformer makes sure that only differential/symmetrical current flows through the input part.
  2. Question 1 Capacitor C5 does not play role of any feedback! This is again part of a common-mode suppresion, and is referred to as Y-capactor. Here let me quote one user manual:

Line filter capacitors are classified either as X-capacitors or Y-capacitors. X-capacitors are connected between line and neutral, to protect against differential mode interference. Their failure does not create conditions for dangerous electric shock, although it can create a fire risk. However Y-capacitors are designed to filter out common-mode noise, and are connected between line and chassis; if they short-circuit, they create a risk of shock to the user.Y-capacitors are designed to enhanced electrical and mechanical reliability standards. Capacitance values are also limited to reduce the current passing through the capacitor when AC voltage is applied, and reduce the energy stored to a safe limit when DC voltage is applied. Capacitors must be tested to applicable standards to qualify them for use as Y-capacitors.

  1. Question 2 Your circuit works as a buck-converter, which means that after the transforming and rectifying your DC level is anything between 5 and 20V. With the help of the diode, inductor and optocoupler as feedback you can reduce it to more or less stable 5V. Optocoupler basically works as a PWM-controlled switch to ensure the stable output.