Can someone clear this confusion I have about the first law of thermodynamics
Everything you've written is correct (for a free expansion, $\Delta U = q = w = 0$), but it applies only if the system is an ideal gas, or has ideal-gas-like properties, namely that there are no attractive or repulsive interactions between the particles.
It also requires that the system is closed (no matter can flow into or out of the system). Internal energy is an extensive property, so its value is proportional to the amount of substance in the system. If matter is added to the system, internal energy can increase even if no there is no flow of work or heat.
Your teacher probably had both of these restrictions in mind.
Thus, if you expand an ideal gas isothermally into a vacuum, the system doesn't do any work, so $w=0$. And there is thus no need to flow heat into the system to compensate for the work to maintain the temperature, nor is there any need to flow heat into the system to provide energy to pull the particles apart (no interaction between the particles), so $q=0$.
If you want a molecular explanation, imagine an expansion against a constant external pressure.  As the piston retreats, the particles hitting the piston move more slowly after they reflect off of it (this is because they are colliding with a retreating object rather than a stationary object), which has the effect of cooling the gas (the temperature is a measure of how fast the particles are moving).  Thus, for an isothermal expansion in which work is done against some external pressure, to maintain the temperature, heat must flow into the system to compensate for this.
But for a free expansion, the gas isn't expanding against a retreating piston. So particles are not robbed of their kinetic energy and thus, in a free isothermal expansion (of an ideal gas), no compensating heat flow is required to maintain the temperature.