While inside, the lenses of your glasses had cooled to the point that when you walked outside, they were cooler than the dew point temperature of the air outside. The water vapor in the relatively warmer, and more moist air condensed, hence fogging your glasses.