You omit the dot at the start of a file extension which means that if the user types in (for example) "txt" the search will pick up and count files like mytxt.doc, matxt.jpg, etc. You could narrow it down by searching for the dot as well but you are still going to pick up myfile.txtjpg.zip etc.
Why not restrict the inner search using a wildcard (no dot before ext here)
for /f "tokens=*" %%a in ( 'dir /s %%q\*.%ext% ^| find /c "."' ) do (