I don't fully understand the problem but I guess that after preprocessing some categories contain less documents than before. Is that your problem?
This can happen is all terms of some documents are filtered out due to filtering steps in preprocessing. For doucments with 0 terms there will be no row in the bag of words. This means that there will be no document vector row for these documents.