When does the transformer equation hold?
The most basic and important assumption required for the equation to hold is that all of the flux generated in one coil (primary or secondary) passes through the other coil. For this assumption to be true, generally a magnetic core is needed to trap and guide the flux from one coil to the other. Without the core, much of the magnetic flux generated by one coil does not pass through the other coil.

After that, there are many issues that lead to deviation from the ideal behavior, such as various forms of losses.