This answer is based on this Overleaf article
The subfigure package is long outdated, and will generate a 'Missing number' error when there is no error present. This will generate an error, as the subfigure package does not recognise \textwidth as a number, when it is in fact a number (equivalent to the constant width of the total text block on a page). The way to resolve this is to use the more updated subcaption package, which has replaced subfigure.
The above Overleaf article also provides several other possible causes of the error- "Missing number, treated as zero."
Note: Although this answer addresses the same error, i.e., "Missing number, treated as zero.", but caused by different reasons than the original question. However, I believe the answer will be useful to the community as it addresses the issue in general which is use of sufigure package. Moreover, people usually search the error given by latex not the cause. Had the cause of error known to them, they need not search it on google. LOL