It is written in my adapter 5V at 3A and 9V at 3A and so on. How is it detected if it is 5V or 9V?
The USB C standard has a Power Delivery Protocol. Basically what happens is the device that you want to charge in question will ask the power supply (power bank, wall outlet, car charger, etc) for a certain voltage. The power supply will respond by either giving the device the requested voltage, or give the device the next lowest available voltage since it is unable to provide the requested voltage.
The amount of power that is used depends on the voltage level that is being used, and ultimately, the max power output of the power supply. So if your power supply is outputting 5V on USB C, the max power it can output is 15W since almost all power supplies have a current output limit of 3A for a 5V voltage output (P = 5V * 3A = 15W). Anything above 5V depends on the power supply itself.