Have patience and read it, don't skim through.
The same question I had a few weeks ago, I got the answer after several hours of brain-storming and searching answers in internet, so I want to share it.
- Beginner level explanation First:
Lets say the transformer is 100% efficient (no heat losses, no hysteresis losses, no eddy current loss, nothing).
The transformer ensures the voltage on the secondary is N2/N1 times the voltage on the primary due to the phenomenon of mutual induction (explained later), i.e. a changing current in the primary results in a voltage in secondary (and a secondary current if the circuit is complete).
Then, say if the load side (secondary) is not connected to any device (say here a resistor), the current in the secondary is bound to be zero as I = V/R (period.) Therefore since the secondary current is zero, and thus the energy dissipated in the secondary = VI = Vs*0=0.
Now according to conservation of energy the wnergy dissipated in secondary must be equal to power in primary * efficiency of transformer and since efficiency is 1 here (100%) therefore the power input in primary is 0 and thus the current in primary is zero.
"So the current in primary doesn't determine the current in secondary, It is the current in secondary (which is in our hand) which determines the current in primary"
You can see this video (by Khan Academy) too if the above concept did not click by now: https://youtu.be/VrbxUQxu0l0
Think about this a few times, it must click in your mind that the above quoted statement is true, make sure you hear the click sound before you read more ;).
But conservation of energy is used so "we" can "calculate" the primary current but what is the "mechanism" that ensures the transformer to automatically manage it and maintains the current draw from primary to feed the required current in secondary?
- More detailed explanation (the mechanism):
The mechanism causing the Vs to be N2/N1 Vp and which lets the primary "know" how much current to pass through it so the secondary current (in our hands) is maintained, is mutual induction, it is a very very long topic if you want to go in depth, I will explain it in short, and give links to some videos which explain it in this question's perspective.
Mutual induction is a phenomenon in which a change in current in one conductor causes a change in current (or development of a voltage) in other conductor by the mechanism of changing magnetic flux linkage causing electric field, governed by Maxwell's 3rd equation or simply Faraday's Law.
To make sure you are in the Same Page:
A Change in Magnetic Flux results in a development of a emf(voltage) across a conductor and if the circuit is complete, there is a current induced.
Now see this video by ElectroBOOM: https://youtu.be/ySx84Ca7BFQ (from 6:02 if you have less time)
Note: See the above video and then read the below conclusion, else it will be very confusing.
As already mentioned in the video, the phenomenon of mutual induction in transformers:
a. There is a changing current in primary which causes a changing magnetic field around the primary and also wrapping the secondary.
b. This changing magnetic field around the primary and secondary induces a voltage and this voltage causes a reverse current in the primary (due to this changing magnetic field) causing the primary current to reduce but it also induces a voltage in the secondary (as it is wrapping it too) , and if a load is connected, there is a changing current induced in the secondary due to this voltage induced in secondary
c. The changing current in secondary causes a changing magnetic field opposite to the first changing magnetic field and thus stopping the reverse current in primary and also the induced current in secondary and as they decrease the fields come back and this mutual induction balance settles at a point of dynamic equilibrium when the primary current is exactly such that it draws exactly the needed current from primary that can maintain the secondary current we are drawing, obeying conservation of energy.
Isn't it beautiful?
Hope it helped you, but you need to wrap your brain around it by watching the video and the answer several times, and unleashing your imaginative power to understand this phenomenon and mechanism properly, if you want to of course.
But we know nothing is 100% efficient according to the 2nd law of thermodynamics and indeed for transformers it is true too, so the primary current is a bit higher than value we calculate assuming the transformer to be 100% efficient such that the (extra bit current * voltage at primary) accounts for all the inefficiencies in the transformer.
Please correct me in comments, if I said something inaccurate or incorrect.