The basic function is just like any private individual that has rupees in hand and wants to import something from say USA (and thus needs USD). He goes to bank and effectively exchanges rupees for USD to use for the import.
There are two main options (for Indian govt)....approach central bank (RBI) or some other USD liquidity source (local or foreign) that will accept rupees (or proxies like bonds/securities) that it has effectively extracted from the economy (at cost) in return. What it chooses in this regard depends on the situation at hand (what gives the best short term and long term cost w.r.t interest rate/REPO/effective seigniorage and which is more relevant etc). Suffice to say in general this will be the central bank most of the time esp with CAD situation + marginal investment grade bond of India.
None of this involves going to RBI and saying "hand me X USD to spend" for free (which would be something you see in a country that could not build up sustainable forex in first place and most likelihood is banana republic outside of the IMF system). The Indian govt has to forego equivalent rupee liquidity or another parallel....it is also legal issue in RBI operation clause. If a hypothetical govt does not do that (i.e just goes to central bank and says give me the USD for nothing in return)...it basically is giving middle finger to its population (and foreign investors) who played by the rules to generate that forex...and will hurt everything badly macroeconomically. Same goes for simply printing extra local currency for specific purpose of buying the USD from central bank (rather than part of overall monetary policy for whole economy).
Actual structural extraction of USD and other forex (and both also cannot be done for "free" either) is nearly strictly for two purposes: exchange rate management policy and also insurance (so the country doesnt face macroeconomic crisis as far as trade etc goes) when there is some sudden negative input in balance of payments (in fact forex stockpile cost significant money long term to have given their "ROI" is very very low....just like financing an insurance policy). The relevance of doing this for a defense purpose only ....would be bad because defense import is a tiny tiny percentage of total import.