I don't really understand the workings of a transformer and how the
voltage and current on the primary side can be the same phase.
Secondary voltage phase angle relative to primary voltage source:
Let's say the primary voltage has a phase angle of 0°
The magnetization current (not the load current) lags by 90°
It lags by 90° because magnetization current feeds the magnetization inductance
That's a simple case of re-arranging: \$V = L\cdot\frac{di}{dt}\$ (for a sine wave): -
Or, the integral of the applied sine wave is a negative cosine wave: -
Image from HyperPhysics: Inductor voltage-current relationship
The magnetic flux in an ideal core is proportional to current
And, the induced secondary EMF is \$-N\cdot\frac{d\Phi}{dt}\$
This puts the induced secondary EMF in phase with the applied voltage on the primary.
The above explanation deals with the situation of producing a secondary induced voltage that is in phase with the primary applied voltage.
Load currents:
If the secondary is connected to a resistive load then, there is secondary load current and, for a 1:1 transformer, that secondary current also flows in the primary IN ADDITION to the magnetization current.
And, when there is a load current (1:1 transformer), the secondary load current is 180° out of phase with the primary load current. The net effect of these two loads currents is that their individual fluxes cancel each other meaning that the only flux in the core is due to the magnetization current. In other words: -
Please don't confuse magnetization current and load current in the primary.
However, the full current entering the primary is the addition of magnetization current and load current. Given a resistive secondary load, the phase angle of actual current entering the primary is somewhere between a few degrees lagging (full load current) and 90° lagging (zero load current).