I assumed you are using images of the shape [3, 224, 224] and set the number of input features accordingly. Apparently your images are smaller, which explains the lower input features.
The .view(output.size(0), -1) flattens the activation into a two dimensional tensor, such that all features will be used by the linear layer.
The last layer before your linear layer outputs an activation volume of shape [batch_size, 16, 16, 16], i.e. 16 channels and a spatial size of 16x16.
Since you would like to use all these features created by your conv net, you usually flatten this activation volume and feed it into a linear layer.
The linear layer(s) learn to predict the class based on these features.
In the first version of your model only the last spatial size (width) was used in the linear layer repeatedly for all other dimensions.
Have a look at Stanford’s CS231n 4 for more information about CNNs.