First know what do you mean by 'Cap ' in Mid cap or Small cap.
Cap stands for Market Capitalization
Market Capitalization = Current Market price per share * no of shares outstanding.
So basically there is a maket capitaization range for each of the category : LARGE cap
MID cap and
SMALL cap
So if the company's Market Capitalization falls under that range then accordingly NSE /BSE categorizes that stock in the MID cap or SMALL cap etc
For Example consider the CNX Midcap 200 index :
For inclusion in the index, the average market capitalisation of a company must range between Rs.0.75 billion to Rs.7.5 billion.